mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge pull request #5410 from UdjinM6/fix_dmnl_cache_issues
fix: resolve two DMNL cache issues
This commit is contained in:
parent
ced5d5cbed
commit
76a96c29ed
@ -1228,9 +1228,14 @@ void CDeterministicMNManager::CleanupCache(int nHeight)
|
||||
std::vector<uint256> toDeleteDiffs;
|
||||
for (const auto& p : mnListsCache) {
|
||||
if (p.second.GetHeight() + LIST_DIFFS_CACHE_SIZE < nHeight) {
|
||||
// too old, drop it
|
||||
toDeleteLists.emplace_back(p.first);
|
||||
continue;
|
||||
}
|
||||
if (tipIndex != nullptr && p.first == tipIndex->GetBlockHash()) {
|
||||
// it's a snapshot for the tip, keep it
|
||||
continue;
|
||||
}
|
||||
bool fQuorumCache = ranges::any_of(Params().GetConsensus().llmqs, [&nHeight, &p](const auto& params){
|
||||
return (p.second.GetHeight() % params.dkgInterval == 0) &&
|
||||
(p.second.GetHeight() + params.dkgInterval * (params.keepOldConnections + 1) >= nHeight);
|
||||
@ -1239,13 +1244,8 @@ void CDeterministicMNManager::CleanupCache(int nHeight)
|
||||
// at least one quorum could be using it, keep it
|
||||
continue;
|
||||
}
|
||||
// no alive quorums using it, see if it was a cache for the tip or for a now outdated quorum
|
||||
if (tipIndex && tipIndex->pprev && (p.first == tipIndex->pprev->GetBlockHash())) {
|
||||
toDeleteLists.emplace_back(p.first);
|
||||
} else if (ranges::any_of(Params().GetConsensus().llmqs,
|
||||
[&p](const auto& llmqParams){ return p.second.GetHeight() % llmqParams.dkgInterval == 0; })) {
|
||||
toDeleteLists.emplace_back(p.first);
|
||||
}
|
||||
// none of the above, drop it
|
||||
toDeleteLists.emplace_back(p.first);
|
||||
}
|
||||
for (const auto& h : toDeleteLists) {
|
||||
mnListsCache.erase(h);
|
||||
|
@ -537,7 +537,7 @@ public:
|
||||
constexpr int llmq_max_blocks() {
|
||||
int max_blocks{0};
|
||||
for (const auto& llmq : Consensus::available_llmqs) {
|
||||
int blocks = llmq.useRotation ? llmq.dkgInterval * 4 : llmq.dkgInterval * llmq.signingActiveQuorumCount;
|
||||
int blocks = (llmq.useRotation ? 1 : llmq.signingActiveQuorumCount) * llmq.dkgInterval;
|
||||
max_blocks = std::max(max_blocks, blocks);
|
||||
}
|
||||
return max_blocks;
|
||||
|
Loading…
Reference in New Issue
Block a user