Skip to content
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

blockchain: Implement new chain view. #1337

Merged
merged 1 commit into from
Jul 9, 2018

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jul 6, 2018

This PR is rebased on #1334.

This implements a new type in the blockchain package that takes advantage of the fact that all block nodes are now in memory to provide a flat view of a specific chain of blocks (a specific branch of the overall block tree) from a given tip all the way back to the genesis block along with several convenience functions such as efficiently comparing two views, quickly finding the fork point (if any) between two views, and O(1) lookup of the node at a specific height.

The view is not currently used, but the intent is that the code will be refactored to make use of these views to simplify and optimize several areas such as best chain selection and reorg logic and finding successor nodes. They will also greatly simplify the process of disconnecting the download logic from the connection logic.

Since the ultimate intent is for there to be a long-lived chain view instance for the current best chain, this also implements efficient handling of setting the tip to new values including domain-specific capacity increase handling which chooses the desired increase amount more intelligently than the default algorithm, which would way overshoot, as well as adds some additional space when the view is initialized.

A comprehensive suite of tests is provided to ensure the chain views behave correctly.

This is work towards #1145.

@davecgh davecgh mentioned this pull request Jul 6, 2018
33 tasks
@davecgh davecgh force-pushed the blockchain_chainview branch 2 times, most recently from 61facd5 to f74966d Compare July 6, 2018 18:43
Copy link
Member

@dajohi dajohi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tOK testnet2 miner

This implements a new type in the blockchain package that takes
advantage of the fact that all block nodes are now in memory to provide
a flat view of a specific chain of blocks (a specific branch of the
overall block tree) from a given tip all the way back to the genesis
block along with several convenience functions such as efficiently
comparing two views, quickly finding the fork point (if any) between two
views, and O(1) lookup of the node at a specific height.

The view is not currently used, but the intent is that the code will be
refactored to make use of these views to simplify and optimize several
areas such as best chain selection and reorg logic and finding successor
nodes.  They will also greatly simplify the process of disconnecting the
download logic from the connection logic.

Since the ultimate intent is for there to be a long-lived chain view
instance for the current best chain, this also implements efficient
handling of setting the tip to new values including domain-specific
capacity increase handling which chooses the desired increase amount
more intelligently than the default algorithm, which would way
overshoot, as well as adds some additional space when the view is
initialized.

A comprehensive suite of tests is provided to ensure the chain views
behave correctly.
Copy link
Member

@jrick jrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so 1337

@davecgh davecgh merged commit 87653ae into decred:master Jul 9, 2018
@davecgh davecgh deleted the blockchain_chainview branch July 9, 2018 19:47
@davecgh davecgh added this to the 1.3.0 milestone Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants