From e3b04fea0c072abdf3cede39ec5e57d69878f7f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Apr 2018 10:43:41 +0300 Subject: [PATCH] Return error if prevblock != best block --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 008bd3197..a9d1223ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2593,6 +2593,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); + if ( hashPrevBlock != view.GetBestBlock() ) + { + fprintf(stderr,"ConnectBlock(): hashPrevBlock != view.GetBestBlock()\n"); + return state.DoS(1, error("ConnectBlock(): hashPrevBlock != view.GetBestBlock()"), + REJECT_INVALID, "hashPrevBlock-not-bestblock"); + } assert(hashPrevBlock == view.GetBestBlock()); // Special case for the genesis block, skipping connection of its transactions