From 1449ae165f6923f8dadf60f132db5fee5bbf4287 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Oct 2018 18:29:33 -1100 Subject: [PATCH] Fix bug in consensus code from miketout for small networks --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0aadc130c..d5adb5d69 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -397,7 +397,7 @@ namespace { if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); - if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) + if (itOld != mapBlockIndex.end() && itOld->second != 0 && itOld->second->nChainWork > 0) { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; @@ -3876,7 +3876,7 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { // Remove the invalidity flag from this block and all its descendants. BlockMap::iterator it = mapBlockIndex.begin(); - while (it != mapBlockIndex.end()) { + while (it != mapBlockIndex.end() && it->second != 0) { if (!it->second->IsValid() && it->second->GetAncestor(nHeight) == pindex) { it->second->nStatus &= ~BLOCK_FAILED_MASK; setDirtyBlockIndex.insert(it->second); @@ -4680,7 +4680,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( 1 ) + if ( 0 ) // miket's fixes in ReconsiderBlock and ProcessBlockAvailability deprecate the need { // without the komodo_ensure call, it is quite possible to get a non-error but null pindex returned from AcceptBlockHeader. In a 2 node network, it will be a long time before that block is reprocessed. Even though restarting makes it rescan, it seems much better to keep the nodes in sync komodo_ensure(pblock,hash);