-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Eliminate unnecessary call to CheckBlock #7225
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
Conversation
|
Concept ACK. If we're going to remove this call can we also drop the As the comment in |
|
CheckBlock is also called in ConnectBlock() [which is the function that does ALL the consensus checks for a block]. utACK sdaftuar@00318f4 I'm also fine with taking CheckBlockHeader() out of CheckBlock() as @fanquake suggests [as long as it's properly moved out where needed, for example, in ConnectBlock()]. As a side note this would very slightly simplify https://github.com/jtimon/bitcoin/commits/libconsensus-f2 so I consider this "libconsensus encapsulation friendly"(TM) [even if nobody ever asked for that kind of approval from me]. |
ProcessNewBlock would return failure early if CheckBlock failed, before calling AcceptBlock. AcceptBlock also calls CheckBlock, and upon failure would update mapBlockIndex to indicate that a block was failed. By returning early in ProcessNewBlock, we were not marking blocks that fail a check in CheckBlock as permanently failed, and thus would continue to re-request and reprocess them.
00318f4 to
dbb89dc
Compare
|
Needed rebase. |
|
Re-utACK dbb89dc |
|
utACK dbb89dc |
dbb89dc Eliminate unnecessary call to CheckBlock (Suhas Daftuar)
ProcessNewBlockwould return failure early ifCheckBlockfailed, before callingAcceptBlock.AcceptBlockalso callsCheckBlock, and upon failure would updatemapBlockIndexto indicate that a block was failed. By returning early inProcessNewBlock, we were not marking blocks that fail a check inCheckBlockas permanently failed, and thus would continue to re-request and reprocess them.This should result in one fewer call to
CheckBlockfor valid blocks, at the expense of one extra call toAcceptBlockHeaderfor blocks that failCheckBlock, and it avoids reprocessing those failed blocks over and over.