@@ -359,9 +359,6 @@ void CDeterministicMNList::PoSeDecrease(const uint256& proTxHash)
359359CDeterministicMNListDiff CDeterministicMNList::BuildDiff (const CDeterministicMNList& to) const
360360{
361361 CDeterministicMNListDiff diffRet;
362- diffRet.prevBlockHash = blockHash;
363- diffRet.blockHash = to.blockHash ;
364- diffRet.nHeight = to.nHeight ;
365362
366363 to.ForEachMN (false , [&](const CDeterministicMNCPtr& toPtr) {
367364 auto fromPtr = GetMN (toPtr->proTxHash );
@@ -418,13 +415,11 @@ CSimplifiedMNListDiff CDeterministicMNList::BuildSimplifiedDiff(const CDetermini
418415 return diffRet;
419416}
420417
421- CDeterministicMNList CDeterministicMNList::ApplyDiff (const CDeterministicMNListDiff& diff) const
418+ CDeterministicMNList CDeterministicMNList::ApplyDiff (const CBlockIndex* pindex, const CDeterministicMNListDiff& diff) const
422419{
423- assert (diff.prevBlockHash == blockHash && diff.nHeight == nHeight + 1 );
424-
425420 CDeterministicMNList result = *this ;
426- result.blockHash = diff. blockHash ;
427- result.nHeight = diff. nHeight ;
421+ result.blockHash = pindex-> GetBlockHash () ;
422+ result.nHeight = pindex-> nHeight ;
428423
429424 for (const auto & id : diff.removedMns ) {
430425 auto dmn = result.GetMNByInternalId (id);
@@ -544,9 +539,9 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
544539 oldList = GetListForBlock (pindex->pprev );
545540 diff = oldList.BuildDiff (newList);
546541
547- evoDb.Write (std::make_pair (DB_LIST_DIFF, diff. blockHash ), diff);
542+ evoDb.Write (std::make_pair (DB_LIST_DIFF, newList. GetBlockHash () ), diff);
548543 if ((nHeight % SNAPSHOT_LIST_PERIOD) == 0 || oldList.GetHeight () == -1 ) {
549- evoDb.Write (std::make_pair (DB_LIST_SNAPSHOT, diff. blockHash ), newList);
544+ evoDb.Write (std::make_pair (DB_LIST_SNAPSHOT, newList. GetBlockHash () ), newList);
550545 LogPrintf (" CDeterministicMNManager::%s -- Wrote snapshot. nHeight=%d, mapCurMNs.allMNsCount=%d\n " ,
551546 __func__, nHeight, newList.GetAllMNsCount ());
552547 }
@@ -929,7 +924,7 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const CBlockIndex*
929924 auto diffIndex = p.first ;
930925 auto & diff = p.second ;
931926 if (diff.HasChanges ()) {
932- snapshot = snapshot.ApplyDiff (diff);
927+ snapshot = snapshot.ApplyDiff (diffIndex, diff);
933928 } else {
934929 snapshot.SetBlockHash (diffIndex->GetBlockHash ());
935930 snapshot.SetHeight (diffIndex->nHeight );
@@ -1013,9 +1008,6 @@ bool CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pi
10131008 oldDiffData >> oldDiff;
10141009
10151010 CDeterministicMNListDiff newDiff;
1016- newDiff.prevBlockHash = oldDiff.prevBlockHash ;
1017- newDiff.blockHash = oldDiff.blockHash ;
1018- newDiff.nHeight = oldDiff.nHeight ;
10191011 size_t addedCount = 0 ;
10201012 for (auto & p : oldDiff.addedMNs ) {
10211013 auto dmn = std::make_shared<CDeterministicMN>(*p.second );
@@ -1030,7 +1022,7 @@ bool CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pi
10301022 }
10311023
10321024 // applies added/removed MNs
1033- newMNList = curMNList.ApplyDiff (newDiff);
1025+ newMNList = curMNList.ApplyDiff (pindexNext, newDiff);
10341026
10351027 // manually apply updated MNs and calc new state diffs
10361028 for (auto & p : oldDiff.updatedMNs ) {
0 commit comments