Simplify the nano::ledger::successor function to make its implementation more obvious.#4484
Merged
clemahieu merged 4 commits intonanocurrency:developfrom Mar 15, 2024
Merged
Conversation
b897c69 to
24e4cfa
Compare
pwojcikdev
reviewed
Mar 14, 2024
| nano::uint128_t account_receivable (store::transaction const &, nano::account const &, bool = false); | ||
| nano::uint128_t weight (nano::account const &); | ||
| std::shared_ptr<nano::block> successor (store::transaction const &, nano::qualified_root const &); | ||
| std::optional<nano::block_hash> successor (store::transaction const &, nano::qualified_root const &) const noexcept; |
Contributor
There was a problem hiding this comment.
Depending on whether qualified root represents a block ( root and previous fields are non zero) or an account ( root is set account and previous is zero) this returns either the next block in chain or account. Is this accurate? How exactly the situation looks like with epoch or epoch-open blocks?
Contributor
Author
There was a problem hiding this comment.
There's an ambiguity there that appeared when epoch blocks were created. Roots are only used for block PoW and vote_req hinting. The successor function gives precedence to the block hash rather than the account number. The net result is that vote_req root hints don't work for epoch-open blocks.
pwojcikdev
previously approved these changes
Mar 14, 2024
… so callsites don't necessarily need to load the block.
Adds ledger::successor convenience functions taking nano::block_hash and expands them to nano::qualified_root so both block successor and account open blocks are searched.
…f there is a successor block.
24e4cfa to
5681836
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes simplifies the way block successors are accessed.
Usages of store::block::successor are changed to ledger::successor.
ledger::successor returns a std::optionalnano::block_hash instead of a std::shared_ptrnano::block which allows users to determine if they want to load the block.
A convenience overload of ledger::successor is added which takes a block_hash and expands it to a qualified_root.