blockchain: Separate full data context checks. #1509
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 separates the block and header context checks to make it more explicit exactly which checks require the availability of the full data for all ancestors and which checks do not.
Currently, all ancestor data is always available due to the way the download and block processing logic is implemented, however, ultimately, the plan is to decouple the chain processing and connection code from the download logic. In order to help pave the way towards that goal, this more clearly delineates the checks by redefining the current meaning of the concept of contextual checks and creating a new concept of positional checks.
Positional checks are defined as those which depend on the position of a block or header within the block chain and have all of the ancestor block headers available, but do NOT have all of the full block data for
all of the ancestor blocks.
Contextual checks are now defined as those which depend on having the full block data for all of the ancestors available, which also implies all of the ancestor block headers are available too.
To that end, this introduces two new functions named
checkBlockHeaderPositional
andcheckBlockPositional
, moves all of the checks which adhere to the aforementioned semantics to the newfunctions, and updates all call sites which invoke the contextual variants to call the positional variants first.