From b239bb24a0a431dcb112dc79cdd234ba61fe7b26 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 12 Feb 2019 22:51:50 +0300 Subject: [PATCH] Do not process blocks in CDeterministicMNManager before dip3 activation (#2698) * Do not process blocks in CDeterministicMNManager before dip3 activation This should save us some cpu/disk on initial sync/reindex * Write initial snapshot on dip3 activation --- src/evo/deterministicmns.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index a35183361fa40..b83576a3ef145 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -447,6 +447,13 @@ CDeterministicMNManager::CDeterministicMNManager(CEvoDB& _evoDb) : bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state, bool fJustCheck) { + AssertLockHeld(cs_main); + + bool fDIP0003Active = VersionBitsState(pindex->pprev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003, versionbitscache) == THRESHOLD_ACTIVE; + if (!fDIP0003Active) { + return true; + } + CDeterministicMNList oldList, newList; CDeterministicMNListDiff diff; @@ -473,7 +480,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde diff = oldList.BuildDiff(newList); evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff); - if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0) { + if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0 || oldList.GetHeight() == -1) { evoDb.Write(std::make_pair(DB_LIST_SNAPSHOT, diff.blockHash), newList); LogPrintf("CDeterministicMNManager::%s -- Wrote snapshot. nHeight=%d, mapCurMNs.allMNsCount=%d\n", __func__, nHeight, newList.GetAllMNsCount());