mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fix: Restore caching in CalcCbTxMerkleRootMNList
(#4951)
This commit is contained in:
parent
abcc14b51e
commit
bdfa322f1f
@ -130,7 +130,7 @@ bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev
|
||||
static uint256 merkleRootCached;
|
||||
static bool mutatedCached{false};
|
||||
|
||||
if (sml.mnList == smlCached.mnList) {
|
||||
if (sml == smlCached) {
|
||||
merkleRootRet = merkleRootCached;
|
||||
if (mutatedCached) {
|
||||
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "mutated-cached-calc-cb-mnmerkleroot");
|
||||
|
@ -115,6 +115,17 @@ uint256 CSimplifiedMNList::CalcMerkleRoot(bool* pmutated) const
|
||||
return ComputeMerkleRoot(leaves, pmutated);
|
||||
}
|
||||
|
||||
bool CSimplifiedMNList::operator==(const CSimplifiedMNList& rhs) const
|
||||
{
|
||||
return mnList.size() == rhs.mnList.size() &&
|
||||
std::equal(mnList.begin(), mnList.end(), rhs.mnList.begin(),
|
||||
[](const std::unique_ptr<CSimplifiedMNListEntry>& left, const std::unique_ptr<CSimplifiedMNListEntry>& right)
|
||||
{
|
||||
return *left == *right;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
CSimplifiedMNListDiff::CSimplifiedMNListDiff() = default;
|
||||
|
||||
CSimplifiedMNListDiff::~CSimplifiedMNListDiff() = default;
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
explicit CSimplifiedMNList(const CDeterministicMNList& dmnList);
|
||||
|
||||
uint256 CalcMerkleRoot(bool* pmutated = nullptr) const;
|
||||
bool operator==(const CSimplifiedMNList& rhs) const;
|
||||
};
|
||||
|
||||
/// P2P messages
|
||||
|
Loading…
Reference in New Issue
Block a user