-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: simplify scan blocks #26780
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
rpc: simplify scan blocks #26780
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
6b88347
to
4fcf035
Compare
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.
Concept ACK
Does this require a release note for the s/filtertype/filter_type/ change?
@@ -2474,8 +2474,9 @@ static RPCHelpMan scanblocks() | |||
} while (start_index != stop_block); | |||
|
|||
ret.pushKV("from_height", start_block_height); | |||
ret.pushKV("to_height", stop_block->nHeight); | |||
ret.pushKV("to_height", start_index->nHeight); // start_index is always the last scanned block here |
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.
For reference,end_range->nHeight
would be a bit easier to read, but is not guaranteed to have a 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.
yeah, the user could have aborted the process at the very beginning.
maybe could change it to:
end_range ? end_range->nHeight : start_index->nHeight;
but I'm not so sure that this makes code easier to read.
Thanks for the review TheCharlatan.
Not necessarily. We branched-off v25 and haven't released yet. It would just need to be back ported. |
The current flow walks-through every block in the active chain until hits the chain tip or processes 10k blocks, then calls `lookupFilterRange()` to obtain all the filters from that particular range. This is only done to obtain the heights range to look up the block filters. Which is unneeded. As `scanblocks` only lookup block filters in the active chain, we can directly calculate the lookup range heights, by using the chain tip, without requiring to traverse the chain block by block.
To tell the user whether the process was aborted or not. Plus, as the process can be aborted prior to the end range, have also changed the "to_height" result value to return the last scanned block instead of the end range block.
4fcf035
to
b922f6b
Compare
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.
ACK b922f6b
ACK b922f6b |
b922f6b rpc: scanblocks, add "completed" flag to the result obj (furszy) ce50acc rpc: scanblocks, do not traverse the whole chain block by block (furszy) Pull request description: Coming from bitcoin#23549 (review) The current `scanblocks` flow walks-through every block in the active chain until hits the chain tip or processes 10k blocks, then calls `lookupFilterRange` function to obtain all filters from that particular range. This is only done to obtain the heights range to look up the block filters. Which is unneeded. As `scanblocks` only lookup block filters in the active chain, we can directly calculate the lookup range heights, by using the chain tip, without requiring to traverse the chain block by block. ACKs for top commit: achow101: ACK b922f6b TheCharlatan: ACK b922f6b Tree-SHA512: 0587e6d9cf87a59184adb2dbc26a4e2bce3a16233594c6c330f69feb49bf7dc63fdacf44fc20308e93441159ebc604c63eb7de19204d3e745a2ff16004892b45
Coming from #23549 (review)
The current
scanblocks
flow walks-through every block in the active chainuntil hits the chain tip or processes 10k blocks, then calls
lookupFilterRange
function to obtain all filters from that particular range.
This is only done to obtain the heights range to look up the block
filters. Which is unneeded.
As
scanblocks
only lookup block filters in the active chain, we candirectly calculate the lookup range heights, by using the chain tip,
without requiring to traverse the chain block by block.