From 4c0ac5734a97482c720b9e68ad22a5df05f8c1fa Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 27 Oct 2019 10:18:06 -0400 Subject: [PATCH] Unbreak things by undoing a line accidentally deleted from LoadBlockIndex, derp --- src/bitcoind.cpp | 14 ++++++------- src/init.cpp | 54 +++++++++++++++++++++++++----------------------- src/main.cpp | 22 +++++++++++++------- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 5cd8f795a..ac4b661cf 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -81,7 +81,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { - fprintf(stderr,"call passport iteration\n"); + //fprintf(stderr,"call passport iteration\n"); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( KOMODO_NSPV_FULLNODE ) @@ -108,7 +108,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) } fShutdown = ShutdownRequested(); } - fprintf(stderr,"%s: fShutdown=%d\n", __FUNCTION__, fShutdown); + //fprintf(stderr,"%s: fShutdown=%d\n", __FUNCTION__, fShutdown); if (threadGroup) { @@ -135,7 +135,7 @@ bool AppInit(int argc, char* argv[]) bool fRet = false; - fprintf(stderr, "%s start, argc=%d\n", __FUNCTION__, argc); + //fprintf(stderr, "%s start, argc=%d\n", __FUNCTION__, argc); // // Parameters // @@ -251,9 +251,9 @@ bool AppInit(int argc, char* argv[]) #endif SoftSetBoolArg("-server", true); - fprintf(stderr,"%s: Running AppInit2()\n", __FUNCTION__); + //fprintf(stderr,"%s: Running AppInit2()\n", __FUNCTION__); fRet = AppInit2(threadGroup, scheduler); - fprintf(stderr,"%s: Finished AppInit2(), fRet=%d\n", __FUNCTION__, fRet); + //fprintf(stderr,"%s: Finished AppInit2(), fRet=%d\n", __FUNCTION__, fRet); } catch (const std::exception& e) { PrintExceptionContinue(&e, "AppInit()"); } catch (...) { @@ -261,13 +261,13 @@ bool AppInit(int argc, char* argv[]) } if (!fRet) { - fprintf(stderr,"%s: Interrupting threadGroup\n", __FUNCTION__); + //fprintf(stderr,"%s: Interrupting threadGroup\n", __FUNCTION__); Interrupt(threadGroup); // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of // the startup-failure cases to make sure they don't result in a hang due to some // thread-blocking-waiting-for-another-thread-during-startup case } else { - fprintf(stderr,"%s: Waiting for Shutdown\n", __FUNCTION__); + //fprintf(stderr,"%s: Waiting for Shutdown\n", __FUNCTION__); WaitForShutdown(&threadGroup); } Shutdown(); diff --git a/src/init.cpp b/src/init.cpp index 6ca43baad..823867585 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -958,11 +958,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError("Error: -sysperms is not allowed in combination with enabled wallet functionality"); #endif } else { - fprintf(stderr,"%s setting umask\n", __FUNCTION__); + //fprintf(stderr,"%s setting umask\n", __FUNCTION__); umask(077); } - fprintf(stderr,"%s tik1\n", __FUNCTION__); + //fprintf(stderr,"%s tik1\n", __FUNCTION__); // Clean shutdown on SIGTERM struct sigaction sa; sa.sa_handler = HandleSIGTERM; @@ -1010,7 +1010,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(_("RPC method z_mergetoaddress requires -experimentalfeatures.")); } } - fprintf(stderr,"%s tik2\n", __FUNCTION__); + //fprintf(stderr,"%s tik2\n", __FUNCTION__); // Set this early so that parameter interactions go to console fPrintToConsole = GetBoolArg("-printtoconsole", false); @@ -1032,7 +1032,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); } - fprintf(stderr,"%s tik3\n", __FUNCTION__); + //fprintf(stderr,"%s tik3\n", __FUNCTION__); if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default if (SoftSetBoolArg("-dnsseed", false)) @@ -1075,7 +1075,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (SoftSetBoolArg("-rescan", true)) LogPrintf("%s: parameter interaction: -zapwallettxes= -> setting -rescan=1\n", __func__); } - fprintf(stderr,"%s tik4\n", __FUNCTION__); + //fprintf(stderr,"%s tik4\n", __FUNCTION__); // Make sure enough file descriptors are available int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1); @@ -1088,7 +1088,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(_("Not enough file descriptors available.")); if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections) nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS; - fprintf(stderr,"nMaxConnections %d\n",nMaxConnections); + //fprintf(stderr,"nMaxConnections %d\n",nMaxConnections); // if using block pruning, then disable txindex // also disable the wallet (for now, until SPV support is implemented in wallet) if (GetArg("-prune", 0)) { @@ -1121,7 +1121,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - fprintf(stderr,"%s tik5\n", __FUNCTION__); + //fprintf(stderr,"%s tik5\n", __FUNCTION__); // Check for -debugnet if (GetBoolArg("-debugnet", false)) InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net.")); @@ -1153,7 +1153,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; fServer = GetBoolArg("-server", false); - fprintf(stderr,"%s tik6\n", __FUNCTION__); + //fprintf(stderr,"%s tik6\n", __FUNCTION__); // block pruning; get the amount of disk space (in MB) to allot for block & undo files int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024; @@ -1241,7 +1241,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) expiryDelta = GetArg("-txexpirydelta", DEFAULT_TX_EXPIRY_DELTA); bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true); fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false); - fprintf(stderr,"%s tik7\n", __FUNCTION__); + //fprintf(stderr,"%s tik7\n", __FUNCTION__); std::string strWalletFile = GetArg("-wallet", "wallet.dat"); #endif // ENABLE_WALLET @@ -1260,7 +1260,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) nLocalServices |= NODE_BLOOM; } nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); - fprintf(stderr,"%s tik8\n", __FUNCTION__); + //fprintf(stderr,"%s tik8\n", __FUNCTION__); #ifdef ENABLE_MINING if (mapArgs.count("-mineraddress")) { @@ -1283,7 +1283,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - fprintf(stderr,"%s tik9\n", __FUNCTION__); + //fprintf(stderr,"%s tik9\n", __FUNCTION__); if (!mapMultiArgs["-nuparams"].empty()) { // Allow overriding network upgrade parameters for testing if (Params().NetworkIDString() != "regtest") { @@ -1329,6 +1329,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) ECC_Start(); globalVerifyHandle.reset(new ECCVerifyHandle()); + /* // set the hash algorithm to use for this chain // Again likely better solution here, than using long IF ELSE. extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1; @@ -1344,8 +1345,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // initialize VerusHashV2 CBlockHeader::SetVerusHashV2(); } + */ - fprintf(stderr,"%s tik10\n", __FUNCTION__); + //fprintf(stderr,"%s tik10\n", __FUNCTION__); // Sanity check if (!InitSanityCheck()) return InitError(_("Initialization sanity check failed. Please check for insanity. Hush is shutting down!")); @@ -1362,7 +1364,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (file) fclose(file); - fprintf(stderr,"%s tik11\n", __FUNCTION__); + //fprintf(stderr,"%s tik11\n", __FUNCTION__); fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str()); try { static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); @@ -1378,7 +1380,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-shrinkdebugfile", !fDebug)) ShrinkDebugFile(); - fprintf(stderr,"%s tik12\n", __FUNCTION__); + //fprintf(stderr,"%s tik12\n", __FUNCTION__); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); LogPrintf("Hush version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); @@ -1403,7 +1405,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(&ThreadScriptCheck); } - fprintf(stderr,"%s tik13\n", __FUNCTION__); + //fprintf(stderr,"%s tik13\n", __FUNCTION__); // Start the lightweight task scheduler thread CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler); @@ -1411,7 +1413,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Count uptime MarkStartTime(); - fprintf(stderr,"%s tik14\n", __FUNCTION__); + //fprintf(stderr,"%s tik14\n", __FUNCTION__); if ((chainparams.NetworkIDString() != "regtest") && GetBoolArg("-showmetrics", 0) && @@ -1421,7 +1423,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(&ThreadShowMetricsScreen); } - fprintf(stderr,"%s tik15\n", __FUNCTION__); + //fprintf(stderr,"%s tik15\n", __FUNCTION__); // These must be disabled for now, they are buggy and we probably don't // want any of libsnark's profiling in production anyway. libsnark::inhibit_profiling_info = true; @@ -1443,7 +1445,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (!AppInitServers(threadGroup)) return InitError(_("Unable to start HTTP server. See debug log for details.")); } - fprintf(stderr,"%s tik16\n", __FUNCTION__); + //fprintf(stderr,"%s tik16\n", __FUNCTION__); int64_t nStart; @@ -1468,7 +1470,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif // ENABLE_WALLET // ********************************************************* Step 6: network initialization - fprintf(stderr,"%s tik17\n", __FUNCTION__); + //fprintf(stderr,"%s tik17\n", __FUNCTION__); RegisterNodeSignals(GetNodeSignals()); // sanitize comments per BIP-0014, format user agent and check total size @@ -1484,7 +1486,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.", strSubVersion.size(), MAX_SUBVERSION_LENGTH)); } - fprintf(stderr,"%s tik18\n", __FUNCTION__); + //fprintf(stderr,"%s tik18\n", __FUNCTION__); if (mapArgs.count("-onlynet")) { std::set nets; @@ -1501,7 +1503,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - fprintf(stderr,"%s tik19\n", __FUNCTION__); + //fprintf(stderr,"%s tik19\n", __FUNCTION__); if (mapArgs.count("-whitelist")) { BOOST_FOREACH(const std::string& net, mapMultiArgs["-whitelist"]) { CSubNet subnet(net); @@ -1527,7 +1529,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) SetNameProxy(addrProxy); SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later } - fprintf(stderr,"%s tik20\n", __FUNCTION__); + //fprintf(stderr,"%s tik20\n", __FUNCTION__); // -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses // -noonion (or -onion=0) disables connecting to .onion entirely @@ -1550,7 +1552,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fDiscover = GetBoolArg("-discover", true); fNameLookup = GetBoolArg("-dns", true); - fprintf(stderr,"%s tik22\n", __FUNCTION__); + //fprintf(stderr,"%s tik22\n", __FUNCTION__); bool fBound = false; if (fListen) { if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) { @@ -1588,7 +1590,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - fprintf(stderr,"%s tik23\n", __FUNCTION__); + //fprintf(stderr,"%s tik23\n", __FUNCTION__); BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"]) AddOneShot(strDest); @@ -1629,7 +1631,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return !fRequestShutdown; } // ********************************************************* Step 7: load block chain - fprintf(stderr,"%s tik24\n", __FUNCTION__); + //fprintf(stderr,"%s tik24\n", __FUNCTION__); fReindex = GetBoolArg("-reindex", false); @@ -1861,7 +1863,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) mempool.ReadFeeEstimates(est_filein); fFeeEstimatesInitialized = true; - fprintf(stderr,"%s tik25\n", __FUNCTION__); + //fprintf(stderr,"%s tik25\n", __FUNCTION__); // ********************************************************* Step 8: load wallet #ifdef ENABLE_WALLET diff --git a/src/main.cpp b/src/main.cpp index be0da83fe..462eb113b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4262,7 +4262,7 @@ static int64_t nTimePostConnect = 0; */ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) { - fprintf(stderr, "%s: Start\n", __FUNCTION__); + //fprintf(stderr, "%s: Start\n", __FUNCTION__); assert(pindexNew->pprev == chainActive.Tip()); // Read block from disk. int64_t nTime1 = GetTimeMicros(); @@ -4352,14 +4352,14 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * if ( KOMODO_LONGESTCHAIN != 0 && (pindexNew->GetHeight() == KOMODO_LONGESTCHAIN || pindexNew->GetHeight() == KOMODO_LONGESTCHAIN+1) ) KOMODO_INSYNC = (int32_t)pindexNew->GetHeight(); else KOMODO_INSYNC = 0; - fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING); + //fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING); /*if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && komodo_broadcast(pblock,8); else if ( ASSETCHAINS_SYMBOL[0] != 0 ) komodo_broadcast(pblock,4);*/ if ( KOMODO_NSPV_FULLNODE ) { - fprintf(stderr,"%s: KOMODO_NSPV_FULLNODE\n", __FUNCTION__); + //fprintf(stderr,"%s: KOMODO_NSPV_FULLNODE\n", __FUNCTION__); if ( ASSETCHAINS_CBOPRET != 0 ) komodo_pricesupdate(pindexNew->GetHeight(),pblock); if ( ASSETCHAINS_SAPLING <= 0 && pindexNew->nTime > KOMODO_SAPLING_ACTIVATION - 24*3600 ) @@ -4375,7 +4375,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * fprintf(stderr, "snapshot completed in: %d seconds\n", (int32_t)(time(NULL)-start)); } } - fprintf(stderr,"%s: returning true\n", __FUNCTION__); + //fprintf(stderr,"%s: returning true\n", __FUNCTION__); return true; } @@ -4439,12 +4439,16 @@ static CBlockIndex* FindMostWorkChain() { /** Delete all entries in setBlockIndexCandidates that are worse than the current tip. */ static void PruneBlockIndexCandidates() { + fprintf(stderr,"%s:, setBlockIndexCandidates.size=%d\n", __FUNCTION__, setBlockIndexCandidates.size() ); // Note that we can't delete the current block itself, as we may need to return to it later in case a // reorganization to a better block fails. std::set::iterator it = setBlockIndexCandidates.begin(); while (it != setBlockIndexCandidates.end() && setBlockIndexCandidates.value_comp()(*it, chainActive.LastTip())) { + fprintf(stderr,"%s:, erasing blockindexcandidate element height=%d, time=%d\n", __FUNCTION__, (*it)->GetHeight(), (*it)->GetBlockTime() ); setBlockIndexCandidates.erase(it++); + //fprintf(stderr,"%s:, erased element\n", __FUNCTION__); } + fprintf(stderr,"%s:, setBlockIndexCandidates.size()=%d\n", __FUNCTION__, setBlockIndexCandidates.size() ); // Either the current tip or a successor of it we're working towards is left in setBlockIndexCandidates. assert(!setBlockIndexCandidates.empty()); } @@ -6080,9 +6084,9 @@ bool static LoadBlockIndexDB() vSortedByHeight.push_back(make_pair(pindex->GetHeight(), pindex)); //komodo_pindex_init(pindex,(int32_t)pindex->GetHeight()); } - //fprintf(stderr,"load blockindexDB paired %u\n",(uint32_t)time(NULL)); + fprintf(stderr,"load blockindexDB paired %u\n",(uint32_t)time(NULL)); sort(vSortedByHeight.begin(), vSortedByHeight.end()); - //fprintf(stderr,"load blockindexDB sorted %u\n",(uint32_t)time(NULL)); + fprintf(stderr,"load blockindexDB sorted %u\n",(uint32_t)time(NULL)); BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight) { CBlockIndex* pindex = item.second; @@ -6092,7 +6096,7 @@ bool static LoadBlockIndexDB() if (pindex->nTx > 0) { if (pindex->pprev) { if (pindex->pprev->nChainTx) { - + pindex->nChainTx = pindex->pprev->nChainTx + pindex->nTx; if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) { pindex->nChainSproutValue = *pindex->pprev->nChainSproutValue + *pindex->nSproutValue; } else { @@ -6138,7 +6142,7 @@ bool static LoadBlockIndexDB() pindexBestHeader = pindex; //komodo_pindex_init(pindex,(int32_t)pindex->GetHeight()); } - //fprintf(stderr,"load blockindexDB chained %u\n",(uint32_t)time(NULL)); + fprintf(stderr,"load blockindexDB chained %u\n",(uint32_t)time(NULL)); // Load block file info pblocktree->ReadLastBlockFile(nLastBlockFile); @@ -6232,6 +6236,8 @@ bool static LoadBlockIndexDB() // Set hashFinalSproutRoot for the end of best chain it->second->hashFinalSproutRoot = pcoinsTip->GetBestAnchor(SPROUT); + fprintf(stderr,"about to prune block index\n"); + PruneBlockIndexCandidates(); double progress;