Merge pull request #5410 from UdjinM6/fix_dmnl_cache_issues

fix: resolve two DMNL cache issues
This commit is contained in:
UdjinM6 2023-06-11 09:57:30 +03:00 committed by pasta
parent ced5d5cbed
commit 76a96c29ed
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
2 changed files with 8 additions and 8 deletions

View File

@ -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())) {
// none of the above, drop it
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);
}
}
for (const auto& h : toDeleteLists) {
mnListsCache.erase(h);

View File

@ -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;