From 598808cfd08a4f440c0b1dd13ce65c99bfa88f22 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 8 Aug 2018 18:30:46 -0700 Subject: [PATCH] blockchain: mark blocks as invalid if they fail connectBlock --- blockchain/chain.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/blockchain/chain.go b/blockchain/chain.go index 8c7e7621..3528a007 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -1144,6 +1144,17 @@ func (b *BlockChain) connectBestChain(node *blockNode, block *btcutil.Block, fla // Connect the block to the main chain. err := b.connectBlock(node, block, view, stxos) if err != nil { + // If we got hit with a rule error, then we'll mark + // 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.SetStatusFlags( + node, statusValidateFailed, + ) + } + + flushIndexState() + return false, err }