Skip to content

Commit

Permalink
Use ForEachMN and GetMN in BuildDiff instead of directly accessing mnMap
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Nov 15, 2018
1 parent f4ec3db commit 6edad37
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,20 @@ CDeterministicMNListDiff CDeterministicMNList::BuildDiff(const CDeterministicMNL
diffRet.blockHash = to.blockHash;
diffRet.nHeight = to.nHeight;

for (const auto& p : to.mnMap) {
const auto fromPtr = mnMap.find(p.first);
to.ForEachMN(false, [&](const CDeterministicMNCPtr& toPtr) {
auto fromPtr = GetMN(toPtr->proTxHash);
if (fromPtr == nullptr) {
diffRet.addedMNs.emplace(p.first, p.second);
} else if (*p.second->pdmnState != *(*fromPtr)->pdmnState) {
diffRet.updatedMNs.emplace(p.first, p.second->pdmnState);
diffRet.addedMNs.emplace(toPtr->proTxHash, toPtr);
} else if (*toPtr->pdmnState != *fromPtr->pdmnState) {
diffRet.updatedMNs.emplace(toPtr->proTxHash, fromPtr->pdmnState);
}
}
for (const auto& p : mnMap) {
const auto toPtr = to.mnMap.find(p.first);
});
ForEachMN(false, [&](const CDeterministicMNCPtr& fromPtr) {
auto toPtr = to.GetMN(fromPtr->proTxHash);
if (toPtr == nullptr) {
diffRet.removedMns.insert(p.first);
diffRet.removedMns.insert(fromPtr->proTxHash);
}
}
});

return diffRet;
}
Expand Down

0 comments on commit 6edad37

Please sign in to comment.