-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blockchain: Cleanup and optimize stake node logic.
This reworks the stake node handling logic a bit to clean it up, slightly optimize it, and to make it easier to decouple the chain processing and connection code from the download logic in the future. To accomplish this, the fetchStakeNode dependence on the getReorganizeNodes function is removed in favor of directly iterating the block nodes in the function as needed. Not only is this more efficient, it also allows the function to return stake nodes for branches regardless of their validation status. Currently, this is irrelevant due to the connection and download logic being tightly coupled. However, it will be necessary in the future when those are separated. Also, the flushing and pruning logic is modified to no longer rely on the download logic being tightly coupled to the the connection logic. In particular, a new function named flushBlockIndex is added as a wrapper to the index flush function which populates stake information in a node before flushing it to the database as needed, and all flushing invocations use the wrapper instead. Finally, the stakeUndoData field is removed since it is only used to avoid some database loads on reorgs that are large enough to exceed the pruning depth, which never happens in practice anyway, so there is no point in using up extra memory for it.
- Loading branch information
Showing
6 changed files
with
164 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.