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: Optimize block locator generation. #1237

Merged
merged 1 commit into from
Jun 1, 2018

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented May 29, 2018

This requires PRs #1229 and #1230.

This significantly optimizes and simplifies the generation of block locators by making use of the fact that all block nodes are now in memory and therefore it is no longer necessary to consult the database for the hashes or worry about issues related to dynamic loading of nodes.

Also, it slightly modifies the algorithm so that the doubling doesn't start for one additional iteration in order to mirror the upstream code. Due to the way block locators are used, this does not change any semantics in terms of requesting and locating blocks.

Finally, the semantics of BlockLocatorFromHash have been changed to return a locator for the current tip in the case the hash is unknown. This is preferable since only including the passed block hash, when it isn't known, could end up leading to causing a redownload of the entire chain under certain circumstances.

This is work towards #1145.

@davecgh davecgh added this to the 1.3.0 milestone Jun 1, 2018
This significantly optimizes and simplifies the generation of block
locators by making use of the fact that all block nodes are now in
memory and therefore it is no longer necessary to consult the database
for the hashes or worry about issues related to dynamic loading of nodes.

Also, it slightly modifies the algorithm so that the doubling doesn't
start for one additional iteration in order to mirror the upstream code.
Due to the way block locators are used, this does not change any
semantics in terms of requesting and locating blocks.

Finally, the semantics of BlockLocatorFromHash have been changed to
return a locator for the current tip in the case the hash is unknown.
This is preferable since only including the passed block hash, when it
isn't known, could end up leading to causing a redownload of the entire
chain under certain circumstances.
@davecgh davecgh merged commit afb80b9 into decred:master Jun 1, 2018
@davecgh davecgh deleted the blockchain_blocklocator branch June 1, 2018 18:19
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.

3 participants