From b85130925bef33690e0ac708a9c48ab99a629adc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Apr 2018 12:42:27 +0300 Subject: [PATCH] Test --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4fdf9710e..af935ef0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3541,6 +3541,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) // Check for duplicate uint256 hash = block.GetHash(); BlockMap::iterator it = mapBlockIndex.find(hash); + BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); if (it != mapBlockIndex.end()) { if ( ASSETCHAINS_STAKED == 0 || it->second != 0 ) // change behavior to allow komodo_ensure to work @@ -3549,6 +3550,11 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) //fprintf(stderr,"addtoblockindex already there %p\n",it->second); return it->second; } + if ( miPrev != mapBlockIndex.end() && (*miPrev).second == 0 ) + { + fprintf(stderr,"edge case of both block and prevblock in the strange state\n") + return(0); // return here to avoid the state of pindex->nHeight not set and pprev NULL + } } // Construct new block index object CBlockIndex* pindexNew = new CBlockIndex(block); @@ -3559,7 +3565,6 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) pindexNew->nSequenceId = 0; BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; pindexNew->phashBlock = &((*mi).first); - BlockMap::iterator miPrev = mapBlockIndex.find(block.hashPrevBlock); if (miPrev != mapBlockIndex.end()) { if ( (pindexNew->pprev= (*miPrev).second) != 0 )