Skip to content

Commit 85e6af4

Browse files
committed
refactor: use Uint256LruHashMap all overcodebase
1 parent c8c6d29 commit 85e6af4

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

src/evo/creditpool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static std::optional<CreditPoolDataPerBlock> GetCreditDataFromBlock(const gsl::n
6868
CreditPoolDataPerBlock blockData;
6969

7070
static Mutex cache_mutex;
71-
static unordered_lru_cache<uint256, CreditPoolDataPerBlock, StaticSaltedHasher> block_data_cache GUARDED_BY(
71+
static Uint256LruHashMap<CreditPoolDataPerBlock> block_data_cache GUARDED_BY(
7272
cache_mutex){static_cast<size_t>(Params().CreditPoolPeriodBlocks()) * 2};
7373
if (LOCK(cache_mutex); block_data_cache.get(block_index->GetBlockHash(), blockData)) {
7474
return blockData;

src/evo/creditpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class CCreditPoolManager
111111
private:
112112
static constexpr size_t CreditPoolCacheSize = 1000;
113113
Mutex cache_mutex;
114-
unordered_lru_cache<uint256, CCreditPool, StaticSaltedHasher> creditPoolCache GUARDED_BY(cache_mutex) {CreditPoolCacheSize};
114+
Uint256LruHashMap<CCreditPool> creditPoolCache GUARDED_BY(cache_mutex) {CreditPoolCacheSize};
115115

116116
CEvoDB& evoDb;
117117

src/evo/mnhftx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CMNHFManager : public AbstractEHFManager
9797
static constexpr size_t MNHFCacheSize = 1000;
9898
Mutex cs_cache;
9999
// versionBit <-> height
100-
unordered_lru_cache<uint256, Signals, StaticSaltedHasher> mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize};
100+
Uint256LruHashMap<Signals> mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize};
101101

102102
public:
103103
explicit CMNHFManager(CEvoDB& evoDb);

src/llmq/blockprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CQuorumBlockProcessor
5151
std::map<std::pair<Consensus::LLMQType, uint256>, uint256> minableCommitmentsByQuorum GUARDED_BY(minableCommitmentsCs);
5252
std::map<uint256, CFinalCommitment> minableCommitments GUARDED_BY(minableCommitmentsCs);
5353

54-
mutable std::map<Consensus::LLMQType, unordered_lru_cache<uint256, bool, StaticSaltedHasher>> mapHasMinedCommitmentCache GUARDED_BY(minableCommitmentsCs);
54+
mutable std::map<Consensus::LLMQType, Uint256LruHashMap<bool>> mapHasMinedCommitmentCache GUARDED_BY(minableCommitmentsCs);
5555

5656
public:
5757
explicit CQuorumBlockProcessor(CChainState& chainstate, CDeterministicMNManager& dmnman, CEvoDB& evoDb,

src/llmq/dkgsessionmgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ MessageProcessingResult CDKGSessionManager::ProcessMessage(CNode& pfrom, bool is
9696
CDataStream& vRecv)
9797
{
9898
static Mutex cs_indexedQuorumsCache;
99-
static std::map<Consensus::LLMQType, unordered_lru_cache<uint256, int, StaticSaltedHasher>> indexedQuorumsCache GUARDED_BY(cs_indexedQuorumsCache);
99+
static std::map<Consensus::LLMQType, Uint256LruHashMap<int>> indexedQuorumsCache GUARDED_BY(cs_indexedQuorumsCache);
100100

101101
if (!IsQuorumDKGEnabled(spork_manager))
102102
return {};

src/llmq/quorums.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ class CQuorumManager
248248
const CSporkManager& m_sporkman;
249249

250250
mutable Mutex cs_map_quorums;
251-
mutable std::map<Consensus::LLMQType, unordered_lru_cache<uint256, CQuorumPtr, StaticSaltedHasher>> mapQuorumsCache GUARDED_BY(cs_map_quorums);
251+
mutable std::map<Consensus::LLMQType, Uint256LruHashMap<CQuorumPtr>> mapQuorumsCache GUARDED_BY(cs_map_quorums);
252252
mutable Mutex cs_scan_quorums;
253253
mutable std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::vector<CQuorumCPtr>, StaticSaltedHasher>> scanQuorumsCache GUARDED_BY(cs_scan_quorums);
254254
mutable Mutex cs_cleanup;
255-
mutable std::map<Consensus::LLMQType, unordered_lru_cache<uint256, uint256, StaticSaltedHasher>> cleanupQuorumsCache GUARDED_BY(cs_cleanup);
255+
mutable std::map<Consensus::LLMQType, Uint256LruHashMap<uint256>> cleanupQuorumsCache GUARDED_BY(cs_cleanup);
256256

257257
mutable Mutex cs_quorumBaseBlockIndexCache;
258258
// On mainnet, we have around 62 quorums active at any point; let's cache a little more than double that to be safe.

src/llmq/snapshot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class CQuorumSnapshotManager
216216

217217
CEvoDB& m_evoDb;
218218

219-
unordered_lru_cache<uint256, CQuorumSnapshot, StaticSaltedHasher> quorumSnapshotCache GUARDED_BY(snapshotCacheCs);
219+
Uint256LruHashMap<CQuorumSnapshot> quorumSnapshotCache GUARDED_BY(snapshotCacheCs);
220220

221221
public:
222222
explicit CQuorumSnapshotManager(CEvoDB& evoDb) :

src/llmq/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,11 +968,11 @@ void InitQuorumsCache(CacheType& cache, bool limit_by_connections)
968968
std::forward_as_tuple(limit_by_connections ? llmq.keepOldConnections : llmq.keepOldKeys));
969969
}
970970
}
971-
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, bool, StaticSaltedHasher>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, bool, StaticSaltedHasher>>& cache, bool limit_by_connections);
971+
template void InitQuorumsCache<std::map<Consensus::LLMQType, Uint256LruHashMap<bool>>>(std::map<Consensus::LLMQType, Uint256LruHashMap<bool>>& cache, bool limit_by_connections);
972972
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::vector<CQuorumCPtr>, StaticSaltedHasher>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::vector<CQuorumCPtr>, StaticSaltedHasher>>& cache, bool limit_by_connections);
973973
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::shared_ptr<llmq::CQuorum>, StaticSaltedHasher, 0ul, 0ul>, std::less<Consensus::LLMQType>, std::allocator<std::pair<Consensus::LLMQType const, unordered_lru_cache<uint256, std::shared_ptr<llmq::CQuorum>, StaticSaltedHasher, 0ul, 0ul>>>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::shared_ptr<llmq::CQuorum>, StaticSaltedHasher, 0ul, 0ul>, std::less<Consensus::LLMQType>, std::allocator<std::pair<Consensus::LLMQType const, unordered_lru_cache<uint256, std::shared_ptr<llmq::CQuorum>, StaticSaltedHasher, 0ul, 0ul>>>>&cache, bool limit_by_connections);
974-
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, int, StaticSaltedHasher>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, int, StaticSaltedHasher>>& cache, bool limit_by_connections);
975-
template void InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, uint256, StaticSaltedHasher>>>(std::map<Consensus::LLMQType, unordered_lru_cache<uint256, uint256, StaticSaltedHasher>>& cache, bool limit_by_connections);
974+
template void InitQuorumsCache<std::map<Consensus::LLMQType, Uint256LruHashMap<int>>>(std::map<Consensus::LLMQType, Uint256LruHashMap<int>>& cache, bool limit_by_connections);
975+
template void InitQuorumsCache<std::map<Consensus::LLMQType, Uint256LruHashMap<uint256>>>(std::map<Consensus::LLMQType, Uint256LruHashMap<uint256>>& cache, bool limit_by_connections);
976976
template void
977977
InitQuorumsCache<std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::pair<uint256, int>, StaticSaltedHasher>>>(
978978
std::map<Consensus::LLMQType, unordered_lru_cache<uint256, std::pair<uint256, int>, StaticSaltedHasher>>& cache,

0 commit comments

Comments
 (0)