quick check for block_exists in adapters #3068
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.
We currently check for
is_known()
when processing blocks but we do this only after we obtain the write lock on the txhashset in chain processing pipeline. This is expensive and causes unnecessary contention around our various write locks where peers can only check this sequentially and are blocked from processing any other p2p messages while waiting for this.We can do a quick (and far less expensive) check in adapters when processing a -
In adapters, quickly check if the full block exists in the db. If it exists we have previously processed and accepted this block and we do not need to process it again.