diff --git a/src/main.cpp b/src/main.cpp index d72f84c3f..e44c13e93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4138,7 +4138,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C AssertLockHeld(cs_main); CBlockIndex *&pindex = *ppindex; - if (!AcceptBlockHeader(futureblockp,block, state, &pindex)) + if (!AcceptBlockHeader(futureblockp, block, state, &pindex)) { if ( *futureblockp == 0 ) { @@ -4342,7 +4342,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo if ( 1 ) { // 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); + komodo_ensure(pblock, hash); } bool ret = AcceptBlock(&futureblock,*pblock, state, &pindex, fRequested, dbp); if (pindex && pfrom) { diff --git a/src/miner.cpp b/src/miner.cpp index 59d962e8f..deeeeab76 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -830,14 +830,24 @@ void static VerusStaker(CWallet *pwallet) waitForPeers(chainparams); // try a nice clean peer connection to start waitForPeers(chainparams); - CBlockIndex* pindexPrev; + CBlockIndex* pindexPrev, *pindexCur; do { - pindexPrev = chainActive.Tip(); + { + LOCK(cs_main); + pindexPrev = chainActive.Tip(); + } MilliSleep(5000 + rand() % 5000); - } while (pindexPrev != chainActive.Tip()); + { + LOCK(cs_main); + pindexCur = chainActive.Tip(); + } + } while (pindexPrev != pindexCur); sleep(5); - printf("Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL); + + { + printf("Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL); + } //fprintf(stderr,"Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL); miningTimer.start(); @@ -1005,11 +1015,18 @@ void static BitcoinMiner_noeq() // try a nice clean peer connection to start waitForPeers(chainparams); - CBlockIndex* pindexPrev; + CBlockIndex *pindexPrev, *pindexCur; do { - pindexPrev = chainActive.Tip(); + { + LOCK(cs_main); + pindexPrev = chainActive.Tip(); + } MilliSleep(5000 + rand() % 5000); - } while (pindexPrev != chainActive.Tip()); + { + LOCK(cs_main); + pindexCur = chainActive.Tip(); + } + } while (pindexPrev != pindexCur); printf("Mining height %d\n", chainActive.Tip()->nHeight + 1);