changed flush to have min height

don't flush blocks on regtest
This commit is contained in:
Brannon King 2019-11-12 22:33:15 -05:00
parent f05b5973ae
commit 37d177178f
2 changed files with 6 additions and 4 deletions

View file

@ -39,7 +39,7 @@ bool BCLog::Logger::OpenDebugLog()
if (fs::exists(m_file_path)) { if (fs::exists(m_file_path)) {
fs::path old_file_path(m_file_path); fs::path old_file_path(m_file_path);
old_file_path.append(".old"); old_file_path += ".old";
fs::rename(m_file_path, old_file_path); fs::rename(m_file_path, old_file_path);
} }

View file

@ -2772,13 +2772,15 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
if (ShutdownRequested()) if (ShutdownRequested())
break; break;
} while (pindexNewTip != pindexMostWork); } while (pindexNewTip != pindexMostWork);
CheckBlockIndex(chainparams.GetConsensus());
auto& consensus = chainparams.GetConsensus();
CheckBlockIndex(consensus);
auto flushMode = FlushStateMode::PERIODIC; auto flushMode = FlushStateMode::PERIODIC;
if (pindexNewTip && pindexNewTip->nTime + chainparams.GetConsensus().nPowTargetSpacing > GetAdjustedTime()) { if (pindexNewTip && chainparams.NetworkIDString() != CBaseChainParams::REGTEST
&& pindexNewTip->nTime + consensus.nPowTargetSpacing > GetAdjustedTime()) {
// trying to ensure that we flush to disk after new blocks when we're caught up to the chain // trying to ensure that we flush to disk after new blocks when we're caught up to the chain
// they're technically allowed to be two hours late, but experience says one minute is more likely // they're technically allowed to be two hours late, but experience says one minute is more likely
// LogPrintf("Added tip with time %d but it is now %ll\n", pindexNewTip->nTime, GetAdjustedTime());
flushMode = FlushStateMode::ALWAYS; flushMode = FlushStateMode::ALWAYS;
} }
return FlushStateToDisk(chainparams, state, flushMode); return FlushStateToDisk(chainparams, state, flushMode);