blockchain: Add ReconsiderBlock()#2196
Merged
Roasbeef merged 2 commits intobtcsuite:masterfrom Jun 19, 2024
Merged
Conversation
reorganizeChain() used to handle the following: 1: That the blocknodes being disconnected/connected indeed to connect properly without errors. 2: Perform the actual disconnect/connect of the blocknodes. The functionality of 1, the validation that the disconnects/connects can happen without errors are now refactored out into verifyReorganizationValidity. This is an effort made so that ReconsiderBlock() can call verifyReorganizationValidity and set the block status of the reconsidered chain and return nil even when an error returns as it's ok to get an error when reconsidering an invalid branch.
ReconsiderBlock reconsiders the validity of the block for the passed in blockhash. The behavior of the function mimics that of Bitcoin Core. The invalid status of the block nodes are reset and if the chaintip that is being reconsidered has more cumulative work, then we'll validate the blocks and reorganize to it. If the cumulative work is lesser than the current active chain tip, then nothing else will be done.
Crypt-iQ
commented
Jun 7, 2024
| // code assumes that it's directly modifying the database so the cache | ||
| // will be left in an inconsistent state. It needs to be flushed beforehand | ||
| // in order for that to not happen. | ||
| err := b.db.Update(func(dbTx database.Tx) error { |
Collaborator
Author
There was a problem hiding this comment.
Outstanding question is whether we need to do this still?
Collaborator
There was a problem hiding this comment.
It wasn't needed here (the PR for when it was added) since the flush on disconnectBlock would always ensure that the right state would be saved to disk.
No need for it to be here and it's ok to remove it.
Pull Request Test Coverage Report for Build 9423714813Details
💛 - Coveralls |
Collaborator
|
Verified that this PR is just a cleanup for the commits:
from #2181 Looks fine for me |
asheswook
pushed a commit
to asheswook/btcd
that referenced
this pull request
Apr 2, 2026
blockchain: Add ReconsiderBlock()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds ReconsiderBlock() on blockchain that will clear up any block validation statuses and re-validate the block. If the block is part of a longer chain, then the chain will reorganize to that chain.
Replaces #2181