-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Daemon RPC: /getblocks.bin optional block_ids_exclusive req param #10143
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
base: master
Are you sure you want to change the base?
Conversation
|
|
0ee2c16 to
ba0cfe4
Compare
Updated to use |
src/cryptonote_core/blockchain.cpp
Outdated
| db_rtxn_guard rtxn_guard(m_db); | ||
| top_hash = m_db->top_block_hash(&total_height); | ||
| ++total_height; | ||
| CHECK_AND_ASSERT_MES(total_height >= start_height, false, "chain height expected to be higher than start block"); |
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.
Minor issue, but the message here doesn't match the assertion (ignores equality); suggest something like: Start height cannot exceed chain height.
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.
Actually it should really be total_height > start_height, good spot
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.
Fixed to check total_height > start_height
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.
Looks OK, apart from the (easily resolved) inaccuracy of the assertion message.
When the request includes block_ids, the daemon uses find_blockchain_supplement to identify the highest block hash passed in block_ids that the daemon also knows about, and then serves subsequent blocks contiguous to that block. When block_ids_skip_exclusive is false (default current behavior), the daemon includes the highest block requested in the response, in addition to contiguous blocks after it. When block_ids_skip_exclusive is true (new param), the daemon serves blocks starting from the block 1 higher than the highest known block included in block_ids. Thus, the daemon skips the common block known to the client and daemon. Clients can make sure the daemon is serving expected contiguous blocks to its highest known block by checking the first block's prev_id included in the response, and making sure it is equivalent to the block the client already knows about that was included in block_ids. This avoids the daemon serving 1 extra block it does not need to serve to the client, since the client should already know about that block. bl
ba0cfe4 to
4a2d6eb
Compare
When the request includes
block_ids, the daemon usesfind_blockchain_supplementto identify the highest block hash passed inblock_idsthat the daemon also knows about, and then serves subsequent blocks contiguous to that block.When
block_ids_exclusiveis false (default current behavior), the daemon includes the highest block requested in the response, in addition to contiguous blocks after it.When
block_ids_exclusiveis true (new param), the daemon serves blocks starting from the block 1 higher than the highest known block included inblock_ids. Thus, the daemon skips the common block known to the client and daemon. Clients can make sure the daemon is serving expected contiguous blocks to its highest known block by checking the first block'sprev_idincluded in the response, and making sure it is equivalent to the block the client already knows about that was included inblock_ids. This avoids the daemon serving 1 extra block it does not need to serve to the client, since the client should already know about that block.This optimization is used in the FCMP++ integration wallet2 refresh, implemented as part of this PR refactoring wallet2 refresh: seraphis-migration#81