blockchain: Split block and header validation. #386
Merged
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.
This pull request refactors the consensus rule checks for block headers and blocks in the blockchain package into separate functions. These changes contain no modifications to consensus rules and the code still passes all block consensus tests. It is only a refactoring.
This is being done to help pave the way toward supporting concurrent downloads. While the package already supports headers-first mode up through the latest checkpoint through the use of the BFFastAdd flag and hard-coded checkpoints, it currently only works when downloading from a single peer. In order to support concurrent downloads from multiple peers, the ability for the caller to do things such as independently checking a block header (both context-free and full-context checks) will be needed.
There are several more changes that will be necessary to support concurrent downloads as well, such as making the package concurrent safe, modifying it to make use of the new database API, etc. Those changes are planned for future commits.