-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get confirmed + unconfirmed unspent boxes EP #246
Conversation
val ergoTree = addressToErgoTreeHex(address) | ||
(for { | ||
nConfirmed <- outputs.countUnspentByErgoTree(ergoTree) | ||
nUnonfirmed <- uoutputs.sumUnspentByErgoTree(ergoTree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nUnonfirmed <- uoutputs.sumUnspentByErgoTree(ergoTree) | |
nUnсonfirmed <- uoutputs.sumUnspentByErgoTree(ergoTree) |
val ergoTree = addressToErgoTreeHex(address) | ||
(for { | ||
nConfirmed <- outputs.countUnspentByErgoTree(ergoTree) | ||
nUnonfirmed <- uoutputs.sumUnspentByErgoTree(ergoTree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please look careful at what sumUnspentByErgoTree
really does
Line 191 in 44c1acb
|select coalesce(cast(sum(o.value) as bigint), 0) from node_u_outputs o |
confirmed <- outputs | ||
.streamUnspentByErgoTree(ergoTree, paging.offset, paging.limit, ord.value) | ||
.chunkN(serviceSettings.chunkSize) | ||
.through(toOutputInfo) | ||
.map(UOutputInfo.fromOutputInfo) | ||
.to[List] | ||
unconfirmed <- Stream | ||
.evalSeq( | ||
uoutputs | ||
.getAllUnspentByErgoTree(ergoTree) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems your paging doesn't work as it should here. You retrieve a slice of expected number of confirmed outputs streamUnspentByErgoTree(ergoTree, paging.offset, paging.limit, ord.value)
and then concatenate it with unknown number of unconfirmed outputs.
val q = sql""" | ||
|select * from ( | ||
|select distinct on (o.box_id) | ||
| o.box_id, | ||
| o.tx_id, | ||
| o.value, | ||
| o.creation_height, | ||
| o.index, | ||
| o.ergo_tree, | ||
| o.ergo_tree_template_hash, | ||
| o.address, | ||
| o.additional_registers, | ||
| null | ||
|from node_u_outputs o | ||
|left join node_u_inputs i on i.box_id = o.box_id | ||
|where i.box_id is null and o.ergo_tree = $ergoTree | ||
|union all | ||
|select distinct on (o.box_id, o.global_index) | ||
| o.box_id, | ||
| o.tx_id, | ||
| o.value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent SQL
.in(PathPrefix / "unspent" / "all" / "byAddress" / path[Address]) | ||
.in(paging(settings.maxEntitiesPerRequest)) | ||
.in(ordering) | ||
.out(jsonBody[Items[UOutputInfo]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not shrink OutputInfo
down to UOutputInfo
(omitting some fields). I'd suggest adding new coproduct that contains both variants (AnyOutputInfo = OutputInfo | UOutputInfo
).
may help you and can be used as reference |
#245