From 658d4954b838c52e7227c775583eb3a1062a4a72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Apr 2018 10:47:34 +0300 Subject: [PATCH] Return error instead of assert if prevhash != best block --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 97a71b351..67adac1b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2455,6 +2455,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