Skip to content

Commit

Permalink
Do not process blocks in CDeterministicMNManager before dip3 activati…
Browse files Browse the repository at this point in the history
…on (#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
  • Loading branch information
UdjinM6 committed Feb 12, 2019
1 parent 86fc050 commit b239bb2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand Down

0 comments on commit b239bb2

Please sign in to comment.