Skip to content

Commit b239bb2

Browse files
authored
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
1 parent 86fc050 commit b239bb2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/evo/deterministicmns.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,13 @@ CDeterministicMNManager::CDeterministicMNManager(CEvoDB& _evoDb) :
447447

448448
bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state, bool fJustCheck)
449449
{
450+
AssertLockHeld(cs_main);
451+
452+
bool fDIP0003Active = VersionBitsState(pindex->pprev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003, versionbitscache) == THRESHOLD_ACTIVE;
453+
if (!fDIP0003Active) {
454+
return true;
455+
}
456+
450457
CDeterministicMNList oldList, newList;
451458
CDeterministicMNListDiff diff;
452459

@@ -473,7 +480,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
473480
diff = oldList.BuildDiff(newList);
474481

475482
evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff);
476-
if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0) {
483+
if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0 || oldList.GetHeight() == -1) {
477484
evoDb.Write(std::make_pair(DB_LIST_SNAPSHOT, diff.blockHash), newList);
478485
LogPrintf("CDeterministicMNManager::%s -- Wrote snapshot. nHeight=%d, mapCurMNs.allMNsCount=%d\n",
479486
__func__, nHeight, newList.GetAllMNsCount());

0 commit comments

Comments
 (0)