Skip to content

Commit

Permalink
[lbry] blockchain: clear statusValid upon statusValidateFailed is set
Browse files Browse the repository at this point in the history
The status management of index does need some refactoring.
For now, we just manually clear the statusValid in every occurance
of statusValidateFailed being set.

Co-authored-by: Roy Lee <roylee17@gmail.com>
  • Loading branch information
BrannonKing and roylee17 committed Dec 30, 2021
1 parent 8b11a93 commit 92a934d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ func (b *BlockChain) reorganizeChain(detachNodes, attachNodes *list.List) error
err = b.checkConnectBlock(n, block, view, nil)
if err != nil {
if _, ok := err.(RuleError); ok {
b.index.UnsetStatusFlags(n, statusValid)
b.index.SetStatusFlags(n, statusValidateFailed)
for de := e.Next(); de != nil; de = de.Next() {
dn := de.Value.(*blockNode)
Expand Down Expand Up @@ -1141,6 +1142,7 @@ func (b *BlockChain) connectBestChain(node *blockNode, block *btcutil.Block, fla
if err == nil {
b.index.SetStatusFlags(node, statusValid)
} else if _, ok := err.(RuleError); ok {
b.index.UnsetStatusFlags(node, statusValid)
b.index.SetStatusFlags(node, statusValidateFailed)
} else {
return false, err
Expand Down Expand Up @@ -1175,6 +1177,7 @@ func (b *BlockChain) connectBestChain(node *blockNode, block *btcutil.Block, fla
// that status of the block as invalid and flush the
// index state to disk before returning with the error.
if _, ok := err.(RuleError); ok {
b.index.UnsetStatusFlags(node, statusValid)
b.index.SetStatusFlags(
node, statusValidateFailed,
)
Expand Down

0 comments on commit 92a934d

Please sign in to comment.