From 6d84700d44281e904a56e3e39f8d0b40b81dc083 Mon Sep 17 00:00:00 2001 From: miketout Date: Sat, 25 Aug 2018 10:48:40 -0700 Subject: [PATCH] Enable syncing of new test chains before checkpoints have started --- src/komodo_gateway.h | 2 +- src/main.cpp | 18 ++++++++++++------ src/miner.cpp | 2 +- src/wallet/wallet.cpp | 2 ++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6a8ef310b..183b6bb54 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -760,7 +760,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); + fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangeout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched); return(-1); } } diff --git a/src/main.cpp b/src/main.cpp index 85af5ef2a..84a05bdbd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1936,21 +1936,27 @@ bool IsInitialBlockDownload() bool IsInSync() { const CChainParams& chainParams = Params(); + CBlockIndex *pbi; + LOCK(cs_main); if (fImporting || fReindex) { //fprintf(stderr,"IsInitialBlockDownload: fImporting %d || %d fReindex\n",(int32_t)fImporting,(int32_t)fReindex); return false; } - if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints())) + if (fCheckpointsEnabled) { - //fprintf(stderr,"IsInitialBlockDownload: checkpoint -> initialdownload\n"); - return false; + pbi = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); + if (fCheckpointsEnabled && pbi && (chainActive.Height() < pbi->nHeight)) + { + //fprintf(stderr,"IsInitialBlockDownload: checkpoint -> initialdownload\n"); + return false; + } } - CBlockIndex *ptr = chainActive.Tip(); - if ( !ptr ) + pbi = chainActive.Tip(); + if ( !pbi ) return false; - else if ( pindexBestHeader != 0 && (pindexBestHeader->nHeight - 1) > ptr->nHeight ) + else if ( pindexBestHeader != 0 && ((pindexBestHeader->nHeight - 1) > pbi->nHeight) ) return false; return true; diff --git a/src/miner.cpp b/src/miner.cpp index 908fd601f..2c14d28d8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -796,7 +796,7 @@ int32_t waitForPeers(const CChainParams &chainparams) LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!IsInSync() || fvNodesEmpty) + if (fvNodesEmpty || !IsInSync()) { do { MilliSleep(100 + rand() % 400); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f9198e487..6b6bbdd35 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2346,6 +2346,8 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) if ( wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-KOMODO_MAXMEMPOOLTIME ) { LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now); + //TODO: EraseFromWallet(wtx.GetHash()); //should be erased, but this creates issues, likely better to create + // vector and do it outside of this loop, but for later continue; } }