Skip to content

Commit 8a68ec6

Browse files
committed
fix: remove duplicated check for hash existance in map, avoid hash recalculation
1 parent b75e640 commit 8a68ec6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/evo/deterministicmns.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,8 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlockInternal(gsl::not_n
785785

786786
if (tipIndex) {
787787
// always keep a snapshot for the tip
788-
if (snapshot.GetBlockHash() == tipIndex->GetBlockHash()) {
789-
auto hash = snapshot.GetBlockHash();
790-
if (mnListsCache.find(hash) == mnListsCache.end()) {
791-
mnListsCache.emplace(snapshot.GetBlockHash(), snapshot);
792-
}
788+
if (const auto snapshot_hash = snapshot.GetBlockHash(); snapshot_hash == tipIndex->GetBlockHash()) {
789+
mnListsCache.emplace(snapshot_hash, snapshot);
793790
} else {
794791
// keep snapshots for yet alive quorums
795792
if (ranges::any_of(Params().GetConsensus().llmqs,
@@ -799,7 +796,7 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlockInternal(gsl::not_n
799796
(snapshot.GetHeight() + params.dkgInterval * (params.keepOldConnections + 1) >=
800797
tipIndex->nHeight);
801798
})) {
802-
mnListsCache.emplace(snapshot.GetBlockHash(), snapshot);
799+
mnListsCache.emplace(snapshot_hash, snapshot);
803800
}
804801
}
805802
}

0 commit comments

Comments
 (0)