From d7cd9abe4445b126ab0e11342b5bb159e31b2b53 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 18:26:53 +0700 Subject: [PATCH 1/7] refactor: define helpers Uint256HashMap, Uint256HashSet, Uint256LruHashMap for code simplification --- src/saltedhasher.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/saltedhasher.h b/src/saltedhasher.h index aa246c301e8c3..f7e075ffdd1ec 100644 --- a/src/saltedhasher.h +++ b/src/saltedhasher.h @@ -9,6 +9,9 @@ #include #include +#include +#include + /** Helper classes for std::unordered_map and std::unordered_set hashing */ template struct SaltedHasherImpl; @@ -73,4 +76,16 @@ struct StaticSaltedHasher } }; + +template +using Uint256HashMap = std::unordered_map; + +using Uint256HashSet = std::unordered_set; + + +template +class unordered_lru_cache; +template +using Uint256LruHashMap = unordered_lru_cache; + #endif // BITCOIN_SALTEDHASHER_H From 3aaf33070220ca0f78bf5dad324f89a099525817 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 18:35:53 +0700 Subject: [PATCH 2/7] refactor: use Uint256HashSet all over codebase --- src/chainlock/chainlock.cpp | 2 +- src/chainlock/chainlock.h | 2 +- src/chainlock/signing.cpp | 8 ++++---- src/chainlock/signing.h | 6 +++--- src/instantsend/db.cpp | 2 +- src/instantsend/instantsend.cpp | 8 ++++---- src/instantsend/instantsend.h | 6 +++--- src/instantsend/signing.cpp | 2 +- src/instantsend/signing.h | 4 ++-- src/llmq/dkgsession.h | 4 ++-- src/llmq/quorums.cpp | 2 +- src/llmq/signing.cpp | 2 +- src/llmq/signing_shares.cpp | 6 +++--- src/llmq/utils.cpp | 14 +++++++------- src/llmq/utils.h | 4 ++-- src/net.cpp | 8 ++++---- src/net.h | 10 +++++----- 17 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/chainlock/chainlock.cpp b/src/chainlock/chainlock.cpp index 8026e2e887657..b07c8ae42c156 100644 --- a/src/chainlock/chainlock.cpp +++ b/src/chainlock/chainlock.cpp @@ -113,7 +113,7 @@ chainlock::ChainLockSig CChainLocksHandler::GetBestChainLock() const return bestChainLock; } -void CChainLocksHandler::UpdateTxFirstSeenMap(const std::unordered_set& tx, const int64_t& time) +void CChainLocksHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) { AssertLockNotHeld(cs); LOCK(cs); diff --git a/src/chainlock/chainlock.h b/src/chainlock/chainlock.h index 297f0ef3168b1..0511edbcf75d7 100644 --- a/src/chainlock/chainlock.h +++ b/src/chainlock/chainlock.h @@ -87,7 +87,7 @@ class CChainLocksHandler final : public chainlock::ChainLockSignerParent EXCLUSIVE_LOCKS_REQUIRED(!cs); chainlock::ChainLockSig GetBestChainLock() const EXCLUSIVE_LOCKS_REQUIRED(!cs); - void UpdateTxFirstSeenMap(const std::unordered_set& tx, const int64_t& time) override + void UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) override EXCLUSIVE_LOCKS_REQUIRED(!cs); [[nodiscard]] MessageProcessingResult ProcessNewChainLock(NodeId from, const chainlock::ChainLockSig& clsig, diff --git a/src/chainlock/signing.cpp b/src/chainlock/signing.cpp index ef5a3513f9901..3524fd2044668 100644 --- a/src/chainlock/signing.cpp +++ b/src/chainlock/signing.cpp @@ -158,7 +158,7 @@ void ChainLockSigner::UpdateBlockHashTxidMap(const uint256& hash, const std::vec if (it == blockTxs.end()) { // We must create this entry even if there are no lockable transactions in the block, so that TrySignChainTip // later knows about this block - it = blockTxs.emplace(hash, std::make_shared>()).first; + it = blockTxs.emplace(hash, std::make_shared()).first; } auto& txids = *it->second; for (const auto& tx : vtx) { @@ -200,7 +200,7 @@ ChainLockSigner::BlockTxs::mapped_type ChainLockSigner::GetBlockTxs(const uint25 return nullptr; } - ret = std::make_shared>(); + ret = std::make_shared(); for (const auto& tx : block.vtx) { if (tx->IsCoinBase() || tx->vin.empty()) { continue; @@ -243,10 +243,10 @@ MessageProcessingResult ChainLockSigner::HandleNewRecoveredSig(const llmq::CReco return m_clhandler.ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig)); } -std::vector>> ChainLockSigner::Cleanup() +std::vector> ChainLockSigner::Cleanup() { AssertLockNotHeld(cs_signer); - std::vector>> removed; + std::vector> removed; LOCK2(::cs_main, cs_signer); for (auto it = blockTxs.begin(); it != blockTxs.end();) { const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(it->first); diff --git a/src/chainlock/signing.h b/src/chainlock/signing.h index 18a7727cf8e14..c769ca3aa6ef2 100644 --- a/src/chainlock/signing.h +++ b/src/chainlock/signing.h @@ -34,7 +34,7 @@ class ChainLockSignerParent virtual bool IsEnabled() const = 0; virtual bool IsTxSafeForMining(const uint256& txid) const = 0; [[nodiscard]] virtual MessageProcessingResult ProcessNewChainLock(NodeId from, const ChainLockSig& clsig, const uint256& hash) = 0; - virtual void UpdateTxFirstSeenMap(const std::unordered_set& tx, const int64_t& time) = 0; + virtual void UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) = 0; }; class ChainLockSigner final : public llmq::CRecoveredSigsListener @@ -52,7 +52,7 @@ class ChainLockSigner final : public llmq::CRecoveredSigsListener struct BlockHasher { size_t operator()(const uint256& hash) const { return ReadLE64(hash.begin()); } }; - using BlockTxs = std::unordered_map>, BlockHasher>; + using BlockTxs = std::unordered_map, BlockHasher>; private: mutable Mutex cs_signer; @@ -80,7 +80,7 @@ class ChainLockSigner final : public llmq::CRecoveredSigsListener [[nodiscard]] MessageProcessingResult HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig) override EXCLUSIVE_LOCKS_REQUIRED(!cs_signer); - [[nodiscard]] std::vector>> Cleanup() + [[nodiscard]] std::vector> Cleanup() EXCLUSIVE_LOCKS_REQUIRED(!cs_signer); private: diff --git a/src/instantsend/db.cpp b/src/instantsend/db.cpp index 1400b10ceed6c..6378703178284 100644 --- a/src/instantsend/db.cpp +++ b/src/instantsend/db.cpp @@ -359,7 +359,7 @@ std::vector CInstantSendDb::RemoveChainedInstantSendLocks(const uint256 std::vector result; std::vector stack; - std::unordered_set added; + Uint256HashSet added; stack.emplace_back(txid); CDBBatch batch(*db); diff --git a/src/instantsend/instantsend.cpp b/src/instantsend/instantsend.cpp index 37232fcde543e..ddf3520efdcee 100644 --- a/src/instantsend/instantsend.cpp +++ b/src/instantsend/instantsend.cpp @@ -37,9 +37,9 @@ namespace llmq { namespace { template requires std::same_as || std::same_as -std::unordered_set GetIdsFromLockable(const std::vector& vec) +Uint256HashSet GetIdsFromLockable(const std::vector& vec) { - std::unordered_set ret{}; + Uint256HashSet ret{}; if (vec.empty()) return ret; ret.reserve(vec.size()); for (const auto& in : vec) { @@ -230,7 +230,7 @@ instantsend::PendingState CInstantSendManager::ProcessPendingInstantSendLocks() return ret; } -std::unordered_set CInstantSendManager::ProcessPendingInstantSendLocks( +Uint256HashSet CInstantSendManager::ProcessPendingInstantSendLocks( const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, const std::unordered_map, StaticSaltedHasher>& pend, std::vector>& peer_activity) @@ -302,7 +302,7 @@ std::unordered_set CInstantSendManager::ProcessPend LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- verified locks. count=%d, alreadyVerified=%d, vt=%d, nodes=%d\n", __func__, verifyCount, alreadyVerified, verifyTimer.count(), batchVerifier.GetUniqueSourceCount()); - std::unordered_set badISLocks; + Uint256HashSet badISLocks; if (ban && !batchVerifier.badSources.empty()) { LOCK(::cs_main); diff --git a/src/instantsend/instantsend.h b/src/instantsend/instantsend.h index 065a3fd8661c2..81b274ae75202 100644 --- a/src/instantsend/instantsend.h +++ b/src/instantsend/instantsend.h @@ -75,7 +75,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent struct NonLockedTxInfo { const CBlockIndex* pindexMined; CTransactionRef tx; - std::unordered_set children; + Uint256HashSet children; }; mutable Mutex cs_nonLocked; @@ -83,7 +83,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent std::unordered_map nonLockedTxsByOutpoints GUARDED_BY(cs_nonLocked); mutable Mutex cs_pendingRetry; - std::unordered_set pendingRetryTxs GUARDED_BY(cs_pendingRetry); + Uint256HashSet pendingRetryTxs GUARDED_BY(cs_pendingRetry); mutable Mutex cs_timingsTxSeen; std::unordered_map timingsTxSeen GUARDED_BY(cs_timingsTxSeen); @@ -110,7 +110,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent instantsend::PendingState ProcessPendingInstantSendLocks() EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingLocks, !cs_pendingRetry); - std::unordered_set ProcessPendingInstantSendLocks( + Uint256HashSet ProcessPendingInstantSendLocks( const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, const std::unordered_map, StaticSaltedHasher>& pend, std::vector>& peer_activity) diff --git a/src/instantsend/signing.cpp b/src/instantsend/signing.cpp index e76730ec98be8..93d2320f7fa3e 100644 --- a/src/instantsend/signing.cpp +++ b/src/instantsend/signing.cpp @@ -55,7 +55,7 @@ void InstantSendSigner::Stop() m_sigman.UnregisterRecoveredSigsListener(this); } -void InstantSendSigner::ClearInputsFromQueue(const std::unordered_set& ids) +void InstantSendSigner::ClearInputsFromQueue(const Uint256HashSet& ids) { LOCK(cs_input_requests); for (const auto& id : ids) { diff --git a/src/instantsend/signing.h b/src/instantsend/signing.h index a0e02451469ff..c4fd6081017bd 100644 --- a/src/instantsend/signing.h +++ b/src/instantsend/signing.h @@ -57,7 +57,7 @@ class InstantSendSigner final : public llmq::CRecoveredSigsListener * Request ids of inputs that we signed. Used to determine if a recovered signature belongs to an * in-progress input lock. */ - std::unordered_set inputRequestIds GUARDED_BY(cs_input_requests); + Uint256HashSet inputRequestIds GUARDED_BY(cs_input_requests); /** * These are the islocks that are currently in the middle of being created. Entries are created when we observed @@ -78,7 +78,7 @@ class InstantSendSigner final : public llmq::CRecoveredSigsListener void Start(); void Stop(); - void ClearInputsFromQueue(const std::unordered_set& ids) + void ClearInputsFromQueue(const Uint256HashSet& ids) EXCLUSIVE_LOCKS_REQUIRED(!cs_input_requests); void ClearLockFromQueue(const InstantSendLockPtr& islock) diff --git a/src/llmq/dkgsession.h b/src/llmq/dkgsession.h index 2b720967b52a7..fa56e337f4870 100644 --- a/src/llmq/dkgsession.h +++ b/src/llmq/dkgsession.h @@ -298,7 +298,7 @@ class CDKGSession private: std::vector> members; std::map membersMap; - std::unordered_set relayMembers; + Uint256HashSet relayMembers; BLSVerificationVectorPtr vvecContribution; std::vector m_sk_contributions; @@ -390,7 +390,7 @@ class CDKGSession public: [[nodiscard]] CDKGMember* GetMember(const uint256& proTxHash) const; - [[nodiscard]] const std::unordered_set& RelayMembers() const { return relayMembers; } + [[nodiscard]] const Uint256HashSet& RelayMembers() const { return relayMembers; } [[nodiscard]] const CBlockIndex* BlockIndex() const { return m_quorum_base_block_index; } [[nodiscard]] const uint256& ProTx() const { return myProTxHash; } [[nodiscard]] const Consensus::LLMQParams GetParams() const { return params; } diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 9c7e60e46706a..6596ef371f9e4 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -371,7 +371,7 @@ void CQuorumManager::CheckQuorumConnections(CConnman& connman, const Consensus:: LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString()); } } else if (watchOtherISQuorums && !quorum->IsMember(myProTxHash)) { - std::unordered_set connections; + Uint256HashSet connections; const auto& cindexes = utils::CalcDeterministicWatchConnections(llmqParams.type, quorum->m_quorum_base_block_index, quorum->members.size(), 1); for (auto idx : cindexes) { connections.emplace(quorum->members[idx]->proTxHash); diff --git a/src/llmq/signing.cpp b/src/llmq/signing.cpp index 810e543c7f788..59d7a8a8470fa 100644 --- a/src/llmq/signing.cpp +++ b/src/llmq/signing.cpp @@ -564,7 +564,7 @@ bool CSigningManager::ProcessPendingRecoveredSigs(PeerManager& peerman) LogPrint(BCLog::LLMQ, "CSigningManager::%s -- verified recovered sig(s). count=%d, vt=%d, nodes=%d\n", __func__, verifyCount, verifyTimer.count(), recSigsByNode.size()); - std::unordered_set processed; + Uint256HashSet processed; for (const auto& p : recSigsByNode) { NodeId nodeId = p.first; const auto& v = p.second; diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index 29d013eda5777..6f7ad9c89352b 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -1319,7 +1319,7 @@ void CSigSharesManager::Cleanup(const CConnman& connman) { // Now delete sessions which are for inactive quorums LOCK(cs); - std::unordered_set inactiveQuorumSessions; + Uint256HashSet inactiveQuorumSessions; sigShares.ForEach([&quorums, &inactiveQuorumSessions](const SigShareKey&, const CSigShare& sigShare) { if (quorums.count(std::make_pair(sigShare.getLlmqType(), sigShare.getQuorumHash())) == 0) { inactiveQuorumSessions.emplace(sigShare.GetSignHash()); @@ -1334,7 +1334,7 @@ void CSigSharesManager::Cleanup(const CConnman& connman) LOCK(cs); // Remove sessions which were successfully recovered - std::unordered_set doneSessions; + Uint256HashSet doneSessions; sigShares.ForEach([&doneSessions, this](const SigShareKey&, const CSigShare& sigShare) { if (doneSessions.count(sigShare.GetSignHash()) != 0) { return; @@ -1348,7 +1348,7 @@ void CSigSharesManager::Cleanup(const CConnman& connman) } // Remove sessions which timed out - std::unordered_set timeoutSessions; + Uint256HashSet timeoutSessions; for (const auto& [signHash, lastSeenTime] : timeSeenForSessions) { if (now - lastSeenTime >= SESSION_NEW_SHARES_TIMEOUT) { timeoutSessions.emplace(signHash); diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index 245c4d17ec383..f4dc752026d3b 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -732,14 +732,14 @@ uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256 return proTxHash2; } -std::unordered_set GetQuorumConnections( +Uint256HashSet GetQuorumConnections( const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, const CSporkManager& sporkman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound) { if (IsAllMembersConnectedEnabled(llmqParams.type, sporkman)) { auto mns = GetAllQuorumMembers(llmqParams.type, dmnman, qsnapman, pQuorumBaseBlockIndex); - std::unordered_set result; + Uint256HashSet result; for (const auto& dmn : mns) { if (dmn->proTxHash == forMember) { @@ -758,18 +758,18 @@ std::unordered_set GetQuorumConnections( return GetQuorumRelayMembers(llmqParams, dmnman, qsnapman, pQuorumBaseBlockIndex, forMember, onlyOutbound); } -std::unordered_set GetQuorumRelayMembers( +Uint256HashSet GetQuorumRelayMembers( const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound) { auto mns = GetAllQuorumMembers(llmqParams.type, dmnman, qsnapman, pQuorumBaseBlockIndex); - std::unordered_set result; + Uint256HashSet result; auto calcOutbound = [&](size_t i, const uint256& proTxHash) { // Relay to nodes at indexes (i+2^k)%n, where // k: 0..max(1, floor(log2(n-1))-1) // n: size of the quorum/ring - std::unordered_set r{}; + Uint256HashSet r{}; if (mns.size() == 1) { // No outbound connections are needed when there is one MN only. // Also note that trying to calculate results via the algorithm below @@ -859,8 +859,8 @@ bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& LogPrint(BCLog::NET_NETCONN, "%s -- isMember=%d for quorum %s:\n", __func__, isMember, pQuorumBaseBlockIndex->GetBlockHash().ToString()); - std::unordered_set connections; - std::unordered_set relayMembers; + Uint256HashSet connections; + Uint256HashSet relayMembers; if (isMember) { connections = GetQuorumConnections(llmqParams, dmnman, qsnapman, sporkman, pQuorumBaseBlockIndex, myProTxHash, true); diff --git a/src/llmq/utils.h b/src/llmq/utils.h index e34b2137e275f..f09d84ae6dbc5 100644 --- a/src/llmq/utils.h +++ b/src/llmq/utils.h @@ -38,11 +38,11 @@ std::vector GetAllQuorumMembers(Consensus::LLMQType llmqTy bool reset_cache = false); uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2); -std::unordered_set GetQuorumConnections( +Uint256HashSet GetQuorumConnections( const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, const CSporkManager& sporkman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound); -std::unordered_set GetQuorumRelayMembers( +Uint256HashSet GetQuorumRelayMembers( const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound); std::set CalcDeterministicWatchConnections(Consensus::LLMQType llmqType, gsl::not_null pQuorumBaseBlockIndex, size_t memberCount, size_t connectionCount); diff --git a/src/net.cpp b/src/net.cpp index a5ac046186f24..af6b302c9c28d 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -4295,7 +4295,7 @@ bool CConnman::AddPendingMasternode(const uint256& proTxHash) return true; } -void CConnman::SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::unordered_set& proTxHashes) +void CConnman::SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const Uint256HashSet& proTxHashes) { LOCK(cs_vPendingMasternodes); auto it = masternodeQuorumNodes.emplace(std::make_pair(llmqType, quorumHash), proTxHashes); @@ -4304,7 +4304,7 @@ void CConnman::SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint } } -void CConnman::SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::unordered_set& proTxHashes) +void CConnman::SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const Uint256HashSet& proTxHashes) { { LOCK(cs_vPendingMasternodes); @@ -4335,10 +4335,10 @@ bool CConnman::HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint return masternodeQuorumNodes.count(std::make_pair(llmqType, quorumHash)); } -std::unordered_set CConnman::GetMasternodeQuorums(Consensus::LLMQType llmqType) const +Uint256HashSet CConnman::GetMasternodeQuorums(Consensus::LLMQType llmqType) const { LOCK(cs_vPendingMasternodes); - std::unordered_set result; + Uint256HashSet result; for (const auto& p : masternodeQuorumNodes) { if (p.first.first != llmqType) { continue; diff --git a/src/net.h b/src/net.h index 5568fac1ab82f..8d92c1338740a 100644 --- a/src/net.h +++ b/src/net.h @@ -1480,10 +1480,10 @@ friend class CNode; EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex, !mutexMsgProc); bool AddPendingMasternode(const uint256& proTxHash); - void SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::unordered_set& proTxHashes); - void SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::unordered_set& proTxHashes); + void SetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const Uint256HashSet& proTxHashes); + void SetMasternodeQuorumRelayMembers(Consensus::LLMQType llmqType, const uint256& quorumHash, const Uint256HashSet& proTxHashes); bool HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash) const; - std::unordered_set GetMasternodeQuorums(Consensus::LLMQType llmqType) const; + Uint256HashSet GetMasternodeQuorums(Consensus::LLMQType llmqType) const; // also returns QWATCH nodes std::unordered_set GetMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash) const; void RemoveMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash); @@ -1743,8 +1743,8 @@ friend class CNode; std::vector vPendingMasternodes; mutable RecursiveMutex cs_vPendingMasternodes; - std::map, std::unordered_set> masternodeQuorumNodes GUARDED_BY(cs_vPendingMasternodes); - std::map, std::unordered_set> masternodeQuorumRelayMembers GUARDED_BY(cs_vPendingMasternodes); + std::map, Uint256HashSet> masternodeQuorumNodes GUARDED_BY(cs_vPendingMasternodes); + std::map, Uint256HashSet> masternodeQuorumRelayMembers GUARDED_BY(cs_vPendingMasternodes); std::set masternodePendingProbes GUARDED_BY(cs_vPendingMasternodes); mutable Mutex cs_mapSocketToNode; From c8c6d29bf15e32f49e82661f7f2f0797f564ef4b Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 18:48:11 +0700 Subject: [PATCH 3/7] refactor: use Uint256HashMap all over codebase --- src/chainlock/chainlock.h | 2 +- src/evo/deterministicmns.h | 4 ++-- src/instantsend/db.cpp | 4 ++-- src/instantsend/db.h | 2 +- src/instantsend/instantsend.cpp | 6 +++--- src/instantsend/instantsend.h | 2 +- src/instantsend/signing.h | 2 +- src/llmq/dkgsession.cpp | 2 +- src/llmq/signing_shares.cpp | 12 ++++++------ src/llmq/signing_shares.h | 10 +++++----- src/spork.h | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/chainlock/chainlock.h b/src/chainlock/chainlock.h index 0511edbcf75d7..7052605759857 100644 --- a/src/chainlock/chainlock.h +++ b/src/chainlock/chainlock.h @@ -59,7 +59,7 @@ class CChainLocksHandler final : public chainlock::ChainLockSignerParent const CBlockIndex* bestChainLockBlockIndex GUARDED_BY(cs){nullptr}; const CBlockIndex* lastNotifyChainLockBlockIndex GUARDED_BY(cs){nullptr}; - std::unordered_map txFirstSeenTime GUARDED_BY(cs); + Uint256HashMap txFirstSeenTime GUARDED_BY(cs); std::map seenChainLocks GUARDED_BY(cs); diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 9c106c5fe9412..b00a97d3a7848 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -627,8 +627,8 @@ class CDeterministicMNManager CEvoDB& m_evoDb; - std::unordered_map mnListsCache GUARDED_BY(cs); - std::unordered_map mnListDiffsCache GUARDED_BY(cs); + Uint256HashMap mnListsCache GUARDED_BY(cs); + Uint256HashMap mnListDiffsCache GUARDED_BY(cs); const CBlockIndex* tipIndex GUARDED_BY(cs) {nullptr}; const CBlockIndex* m_initial_snapshot_index GUARDED_BY(cs) {nullptr}; diff --git a/src/instantsend/db.cpp b/src/instantsend/db.cpp index 6378703178284..695e297403bfa 100644 --- a/src/instantsend/db.cpp +++ b/src/instantsend/db.cpp @@ -116,7 +116,7 @@ void CInstantSendDb::WriteInstantSendLockArchived(CDBBatch& batch, const uint256 batch.Write(std::make_tuple(DB_ARCHIVED_BY_HASH, hash), true); } -std::unordered_map CInstantSendDb::RemoveConfirmedInstantSendLocks(int nUntilHeight) +Uint256HashMap CInstantSendDb::RemoveConfirmedInstantSendLocks(int nUntilHeight) { LOCK(cs_db); if (nUntilHeight <= best_confirmed_height) { @@ -133,7 +133,7 @@ std::unordered_map CInstantSend it->Seek(firstKey); CDBBatch batch(*db); - std::unordered_map ret; + Uint256HashMap ret; while (it->Valid()) { decltype(firstKey) curKey; if (!it->GetKey(curKey) || std::get<0>(curKey) != DB_MINED_BY_HEIGHT_AND_HASH) { diff --git a/src/instantsend/db.h b/src/instantsend/db.h index c11758c3435ab..ae12fb2abccde 100644 --- a/src/instantsend/db.h +++ b/src/instantsend/db.h @@ -101,7 +101,7 @@ class CInstantSendDb * @param nUntilHeight Removes all IS Locks confirmed up until nUntilHeight * @return returns an unordered_map of the hash of the IS Locks and a pointer object to the IS Locks for all IS Locks which were removed */ - std::unordered_map RemoveConfirmedInstantSendLocks(int nUntilHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_db); + Uint256HashMap RemoveConfirmedInstantSendLocks(int nUntilHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_db); /** * Removes IS Locks from the archive if the tx was confirmed 100 blocks before nUntilHeight * @param nUntilHeight the height from which to base the remove of archive IS Locks diff --git a/src/instantsend/instantsend.cpp b/src/instantsend/instantsend.cpp index ddf3520efdcee..11a34e6ea782e 100644 --- a/src/instantsend/instantsend.cpp +++ b/src/instantsend/instantsend.cpp @@ -236,7 +236,7 @@ Uint256HashSet CInstantSendManager::ProcessPendingInstantSendLocks( std::vector>& peer_activity) { CBLSBatchVerifier batchVerifier(false, true, 8); - std::unordered_map recSigs; + Uint256HashMap recSigs; size_t verifyCount = 0; size_t alreadyVerified = 0; @@ -689,7 +689,7 @@ void CInstantSendManager::HandleFullyConfirmedBlock(const CBlockIndex* pindex) void CInstantSendManager::RemoveMempoolConflictsForLock(const uint256& hash, const instantsend::InstantSendLock& islock) { - std::unordered_map toDelete; + Uint256HashMap toDelete; { LOCK(mempool.cs); @@ -720,7 +720,7 @@ void CInstantSendManager::RemoveMempoolConflictsForLock(const uint256& hash, con void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const instantsend::InstantSendLock& islock) { // Lets first collect all non-locked TXs which conflict with the given ISLOCK - std::unordered_map> conflicts; + std::unordered_map> conflicts; { LOCK(cs_nonLocked); for (const auto& in : islock.inputs) { diff --git a/src/instantsend/instantsend.h b/src/instantsend/instantsend.h index 81b274ae75202..5c3d5ce1aee3f 100644 --- a/src/instantsend/instantsend.h +++ b/src/instantsend/instantsend.h @@ -79,7 +79,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent }; mutable Mutex cs_nonLocked; - std::unordered_map nonLockedTxs GUARDED_BY(cs_nonLocked); + Uint256HashMap nonLockedTxs GUARDED_BY(cs_nonLocked); std::unordered_map nonLockedTxsByOutpoints GUARDED_BY(cs_nonLocked); mutable Mutex cs_pendingRetry; diff --git a/src/instantsend/signing.h b/src/instantsend/signing.h index c4fd6081017bd..6b77a1869860e 100644 --- a/src/instantsend/signing.h +++ b/src/instantsend/signing.h @@ -64,7 +64,7 @@ class InstantSendSigner final : public llmq::CRecoveredSigsListener * recovered signatures for all inputs of a TX. At the same time, we initiate signing of our sigshare for the * islock. When the recovered sig for the islock later arrives, we can finish the islock and propagate it. */ - std::unordered_map creatingInstantSendLocks GUARDED_BY(cs_creating); + Uint256HashMap creatingInstantSendLocks GUARDED_BY(cs_creating); // maps from txid to the in-progress islock std::unordered_map txToCreatingInstantSendLocks GUARDED_BY(cs_creating); diff --git a/src/llmq/dkgsession.cpp b/src/llmq/dkgsession.cpp index 2fb6877728088..bacb6903b6111 100644 --- a/src/llmq/dkgsession.cpp +++ b/src/llmq/dkgsession.cpp @@ -469,7 +469,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions(CConnman& connman) const CDKGLogger logger(*this, __func__, __LINE__); - std::unordered_map protoMap; + Uint256HashMap protoMap; connman.ForEachNode([&](const CNode* pnode) { auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash(); if (verifiedProRegTxHash.IsNull()) { diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index 6f7ad9c89352b..ee33ecaf7c0d3 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -857,7 +857,7 @@ CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery(const CQuorumCPt return v[attempt % v.size()].second; } -void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) +void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) { AssertLockHeld(cs); @@ -954,7 +954,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map>& sigSharesToSend) +void CSigSharesManager::CollectSigSharesToSend(std::unordered_map>& sigSharesToSend) { AssertLockHeld(cs); @@ -1051,7 +1051,7 @@ void CSigSharesManager::CollectSigSharesToSendConcentrated(std::unordered_map>& sigSharesToAnnounce) + std::unordered_map>& sigSharesToAnnounce) { AssertLockHeld(cs); @@ -1110,10 +1110,10 @@ void CSigSharesManager::CollectSigSharesToAnnounce( bool CSigSharesManager::SendMessages(CConnman& connman) { - std::unordered_map> sigSharesToRequest; - std::unordered_map> sigShareBatchesToSend; + std::unordered_map> sigSharesToRequest; + std::unordered_map> sigShareBatchesToSend; std::unordered_map> sigSharesToSend; - std::unordered_map> sigSharesToAnnounce; + std::unordered_map> sigSharesToAnnounce; std::unordered_map> sigSessionAnnouncements; auto addSigSesAnnIfNeeded = [&](NodeId nodeId, const uint256& signHash) EXCLUSIVE_LOCKS_REQUIRED(cs) { diff --git a/src/llmq/signing_shares.h b/src/llmq/signing_shares.h index 8bbd9b24774cb..2a84a11628028 100644 --- a/src/llmq/signing_shares.h +++ b/src/llmq/signing_shares.h @@ -330,7 +330,7 @@ class CSigSharesNodeState CSigSharesInv knows; }; // TODO limit number of sessions per node - std::unordered_map sessions; + Uint256HashMap sessions; std::unordered_map sessionByRecvId; @@ -381,7 +381,7 @@ class CSigSharesManager : public CRecoveredSigsListener CThreadInterrupt workInterrupt; SigShareMap sigShares GUARDED_BY(cs); - std::unordered_map signedSessions GUARDED_BY(cs); + Uint256HashMap signedSessions GUARDED_BY(cs); // stores time of last receivedSigShare. Used to detect timeouts std::unordered_map timeSeenForSessions GUARDED_BY(cs); @@ -477,12 +477,12 @@ class CSigSharesManager : public CRecoveredSigsListener void BanNode(NodeId nodeId, PeerManager& peerman); bool SendMessages(CConnman& connman); - void CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) EXCLUSIVE_LOCKS_REQUIRED(cs); - void CollectSigSharesToSend(std::unordered_map>& sigSharesToSend) EXCLUSIVE_LOCKS_REQUIRED(cs); + void CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) EXCLUSIVE_LOCKS_REQUIRED(cs); + void CollectSigSharesToSend(std::unordered_map>& sigSharesToSend) EXCLUSIVE_LOCKS_REQUIRED(cs); void CollectSigSharesToSendConcentrated(std::unordered_map>& sigSharesToSend, const std::vector& vNodes) EXCLUSIVE_LOCKS_REQUIRED(cs); void CollectSigSharesToAnnounce( const CConnman& connman, - std::unordered_map>& sigSharesToAnnounce) + std::unordered_map>& sigSharesToAnnounce) EXCLUSIVE_LOCKS_REQUIRED(cs); void SignPendingSigShares(const CConnman& connman, PeerManager& peerman); void WorkThreadMain(CConnman& connman, PeerManager& peerman); diff --git a/src/spork.h b/src/spork.h index 62b3433a518c9..6f348a50a93e8 100644 --- a/src/spork.h +++ b/src/spork.h @@ -165,7 +165,7 @@ class SporkStore mutable Mutex cs; - std::unordered_map mapSporksByHash GUARDED_BY(cs); + Uint256HashMap mapSporksByHash GUARDED_BY(cs); std::unordered_map > mapSporksActive GUARDED_BY(cs); public: From 85e6af4bbea5e01ee42c69e468c5b233b482c0cf Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 18:53:48 +0700 Subject: [PATCH 4/7] refactor: use Uint256LruHashMap all overcodebase --- src/evo/creditpool.cpp | 2 +- src/evo/creditpool.h | 2 +- src/evo/mnhftx.h | 2 +- src/llmq/blockprocessor.h | 2 +- src/llmq/dkgsessionmgr.cpp | 2 +- src/llmq/quorums.h | 4 ++-- src/llmq/snapshot.h | 2 +- src/llmq/utils.cpp | 6 +++--- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index ab664bc06c80a..b4f89adae46a1 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -68,7 +68,7 @@ static std::optional GetCreditDataFromBlock(const gsl::n CreditPoolDataPerBlock blockData; static Mutex cache_mutex; - static unordered_lru_cache block_data_cache GUARDED_BY( + static Uint256LruHashMap block_data_cache GUARDED_BY( cache_mutex){static_cast(Params().CreditPoolPeriodBlocks()) * 2}; if (LOCK(cache_mutex); block_data_cache.get(block_index->GetBlockHash(), blockData)) { return blockData; diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index d12528b164726..603503ae504ca 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -111,7 +111,7 @@ class CCreditPoolManager private: static constexpr size_t CreditPoolCacheSize = 1000; Mutex cache_mutex; - unordered_lru_cache creditPoolCache GUARDED_BY(cache_mutex) {CreditPoolCacheSize}; + Uint256LruHashMap creditPoolCache GUARDED_BY(cache_mutex) {CreditPoolCacheSize}; CEvoDB& evoDb; diff --git a/src/evo/mnhftx.h b/src/evo/mnhftx.h index 2dc38919cf483..e92963e24c4fe 100644 --- a/src/evo/mnhftx.h +++ b/src/evo/mnhftx.h @@ -97,7 +97,7 @@ class CMNHFManager : public AbstractEHFManager static constexpr size_t MNHFCacheSize = 1000; Mutex cs_cache; // versionBit <-> height - unordered_lru_cache mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize}; + Uint256LruHashMap mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize}; public: explicit CMNHFManager(CEvoDB& evoDb); diff --git a/src/llmq/blockprocessor.h b/src/llmq/blockprocessor.h index b080d1afe8c3c..f4f19ae067fe1 100644 --- a/src/llmq/blockprocessor.h +++ b/src/llmq/blockprocessor.h @@ -51,7 +51,7 @@ class CQuorumBlockProcessor std::map, uint256> minableCommitmentsByQuorum GUARDED_BY(minableCommitmentsCs); std::map minableCommitments GUARDED_BY(minableCommitmentsCs); - mutable std::map> mapHasMinedCommitmentCache GUARDED_BY(minableCommitmentsCs); + mutable std::map> mapHasMinedCommitmentCache GUARDED_BY(minableCommitmentsCs); public: explicit CQuorumBlockProcessor(CChainState& chainstate, CDeterministicMNManager& dmnman, CEvoDB& evoDb, diff --git a/src/llmq/dkgsessionmgr.cpp b/src/llmq/dkgsessionmgr.cpp index ead3e12568715..2595967755bd2 100644 --- a/src/llmq/dkgsessionmgr.cpp +++ b/src/llmq/dkgsessionmgr.cpp @@ -96,7 +96,7 @@ MessageProcessingResult CDKGSessionManager::ProcessMessage(CNode& pfrom, bool is CDataStream& vRecv) { static Mutex cs_indexedQuorumsCache; - static std::map> indexedQuorumsCache GUARDED_BY(cs_indexedQuorumsCache); + static std::map> indexedQuorumsCache GUARDED_BY(cs_indexedQuorumsCache); if (!IsQuorumDKGEnabled(spork_manager)) return {}; diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index cc5d110dcd592..3de8f4bfc508f 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -248,11 +248,11 @@ class CQuorumManager const CSporkManager& m_sporkman; mutable Mutex cs_map_quorums; - mutable std::map> mapQuorumsCache GUARDED_BY(cs_map_quorums); + mutable std::map> mapQuorumsCache GUARDED_BY(cs_map_quorums); mutable Mutex cs_scan_quorums; mutable std::map, StaticSaltedHasher>> scanQuorumsCache GUARDED_BY(cs_scan_quorums); mutable Mutex cs_cleanup; - mutable std::map> cleanupQuorumsCache GUARDED_BY(cs_cleanup); + mutable std::map> cleanupQuorumsCache GUARDED_BY(cs_cleanup); mutable Mutex cs_quorumBaseBlockIndexCache; // On mainnet, we have around 62 quorums active at any point; let's cache a little more than double that to be safe. diff --git a/src/llmq/snapshot.h b/src/llmq/snapshot.h index 4efeae4e033e5..2d161ed00faf5 100644 --- a/src/llmq/snapshot.h +++ b/src/llmq/snapshot.h @@ -216,7 +216,7 @@ class CQuorumSnapshotManager CEvoDB& m_evoDb; - unordered_lru_cache quorumSnapshotCache GUARDED_BY(snapshotCacheCs); + Uint256LruHashMap quorumSnapshotCache GUARDED_BY(snapshotCacheCs); public: explicit CQuorumSnapshotManager(CEvoDB& evoDb) : diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index f4dc752026d3b..faf672b7346b2 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -968,11 +968,11 @@ void InitQuorumsCache(CacheType& cache, bool limit_by_connections) std::forward_as_tuple(limit_by_connections ? llmq.keepOldConnections : llmq.keepOldKeys)); } } -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); template void InitQuorumsCache, StaticSaltedHasher>>>(std::map, StaticSaltedHasher>>& cache, bool limit_by_connections); template void InitQuorumsCache, StaticSaltedHasher, 0ul, 0ul>, std::less, std::allocator, StaticSaltedHasher, 0ul, 0ul>>>>>(std::map, StaticSaltedHasher, 0ul, 0ul>, std::less, std::allocator, StaticSaltedHasher, 0ul, 0ul>>>>&cache, bool limit_by_connections); -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); template void InitQuorumsCache, StaticSaltedHasher>>>( std::map, StaticSaltedHasher>>& cache, From c452f885df9abe94f46c999c482c32ea4890c96a Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 19:17:19 +0700 Subject: [PATCH 5/7] refactor: leftover usages that has not been replaced by automatic script --- src/evo/cbtx.cpp | 2 +- src/instantsend/db.h | 4 ++-- src/instantsend/instantsend.cpp | 2 +- src/instantsend/instantsend.h | 8 ++++---- src/instantsend/signing.h | 2 +- src/llmq/quorums.h | 5 +++-- src/llmq/signing.h | 6 +++--- src/llmq/signing_shares.cpp | 2 +- src/llmq/signing_shares.h | 4 ++-- src/llmq/utils.cpp | 10 +++++----- src/net.cpp | 3 ++- 11 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index d92bb0bee490a..fe762b089b2f0 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -58,7 +58,7 @@ auto CachedGetQcHashesQcIndexedHashes(const CBlockIndex* pindexPrev, const llmq: static Mutex cs_cache; static std::map> quorums_cached GUARDED_BY(cs_cache); - static std::map, StaticSaltedHasher>> qc_hashes_cached + static std::map>> qc_hashes_cached GUARDED_BY(cs_cache); static QcHashMap qcHashes_cached GUARDED_BY(cs_cache); static QcIndexedHashMap qcIndexedHashes_cached GUARDED_BY(cs_cache); diff --git a/src/instantsend/db.h b/src/instantsend/db.h index ae12fb2abccde..6ab07f4be8a57 100644 --- a/src/instantsend/db.h +++ b/src/instantsend/db.h @@ -36,8 +36,8 @@ class CInstantSendDb int best_confirmed_height GUARDED_BY(cs_db){0}; std::unique_ptr db GUARDED_BY(cs_db){nullptr}; - mutable unordered_lru_cache islockCache GUARDED_BY(cs_db); - mutable unordered_lru_cache txidCache GUARDED_BY(cs_db); + mutable Uint256LruHashMap islockCache GUARDED_BY(cs_db); + mutable Uint256LruHashMap txidCache GUARDED_BY(cs_db); mutable unordered_lru_cache outpointCache GUARDED_BY(cs_db); void WriteInstantSendLockMined(CDBBatch& batch, const uint256& hash, int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_db); diff --git a/src/instantsend/instantsend.cpp b/src/instantsend/instantsend.cpp index 11a34e6ea782e..1108d5ee59fd2 100644 --- a/src/instantsend/instantsend.cpp +++ b/src/instantsend/instantsend.cpp @@ -232,7 +232,7 @@ instantsend::PendingState CInstantSendManager::ProcessPendingInstantSendLocks() Uint256HashSet CInstantSendManager::ProcessPendingInstantSendLocks( const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, - const std::unordered_map, StaticSaltedHasher>& pend, + const Uint256HashMap>& pend, std::vector>& peer_activity) { CBLSBatchVerifier batchVerifier(false, true, 8); diff --git a/src/instantsend/instantsend.h b/src/instantsend/instantsend.h index 5c3d5ce1aee3f..a38967194d04a 100644 --- a/src/instantsend/instantsend.h +++ b/src/instantsend/instantsend.h @@ -66,9 +66,9 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent mutable Mutex cs_pendingLocks; // Incoming and not verified yet - std::unordered_map, StaticSaltedHasher> pendingInstantSendLocks GUARDED_BY(cs_pendingLocks); + Uint256HashMap> pendingInstantSendLocks GUARDED_BY(cs_pendingLocks); // Tried to verify but there is no tx yet - std::unordered_map, StaticSaltedHasher> pendingNoTxInstantSendLocks GUARDED_BY(cs_pendingLocks); + Uint256HashMap> pendingNoTxInstantSendLocks GUARDED_BY(cs_pendingLocks); // TXs which are neither IS locked nor ChainLocked. We use this to determine for which TXs we need to retry IS // locking of child TXs @@ -86,7 +86,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent Uint256HashSet pendingRetryTxs GUARDED_BY(cs_pendingRetry); mutable Mutex cs_timingsTxSeen; - std::unordered_map timingsTxSeen GUARDED_BY(cs_timingsTxSeen); + Uint256HashMap timingsTxSeen GUARDED_BY(cs_timingsTxSeen); public: explicit CInstantSendManager(CChainLocksHandler& _clhandler, CChainState& chainstate, CQuorumManager& _qman, @@ -112,7 +112,7 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent Uint256HashSet ProcessPendingInstantSendLocks( const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, - const std::unordered_map, StaticSaltedHasher>& pend, + const Uint256HashMap>& pend, std::vector>& peer_activity) EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingLocks, !cs_pendingRetry); MessageProcessingResult ProcessInstantSendLock(NodeId from, const uint256& hash, diff --git a/src/instantsend/signing.h b/src/instantsend/signing.h index 6b77a1869860e..c86481ef8f17b 100644 --- a/src/instantsend/signing.h +++ b/src/instantsend/signing.h @@ -66,7 +66,7 @@ class InstantSendSigner final : public llmq::CRecoveredSigsListener */ Uint256HashMap creatingInstantSendLocks GUARDED_BY(cs_creating); // maps from txid to the in-progress islock - std::unordered_map txToCreatingInstantSendLocks GUARDED_BY(cs_creating); + Uint256HashMap txToCreatingInstantSendLocks GUARDED_BY(cs_creating); public: explicit InstantSendSigner(CChainState& chainstate, llmq::CChainLocksHandler& clhandler, diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index 3de8f4bfc508f..12d4b8efce88b 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -250,13 +250,14 @@ class CQuorumManager mutable Mutex cs_map_quorums; mutable std::map> mapQuorumsCache GUARDED_BY(cs_map_quorums); mutable Mutex cs_scan_quorums; - mutable std::map, StaticSaltedHasher>> scanQuorumsCache GUARDED_BY(cs_scan_quorums); + mutable std::map>> scanQuorumsCache GUARDED_BY(cs_scan_quorums); mutable Mutex cs_cleanup; mutable std::map> cleanupQuorumsCache GUARDED_BY(cs_cleanup); mutable Mutex cs_quorumBaseBlockIndexCache; // On mainnet, we have around 62 quorums active at any point; let's cache a little more than double that to be safe. - mutable unordered_lru_cache quorumBaseBlockIndexCache; + // it maps `quorum_hash` to `pindex` + mutable Uint256LruHashMap quorumBaseBlockIndexCache; mutable ctpl::thread_pool workerPool; mutable CThreadInterrupt quorumThreadInterrupt; diff --git a/src/llmq/signing.h b/src/llmq/signing.h index b36af4eb8d4a4..06109478f9501 100644 --- a/src/llmq/signing.h +++ b/src/llmq/signing.h @@ -115,8 +115,8 @@ class CRecoveredSigsDb mutable Mutex cs_cache; mutable unordered_lru_cache, bool, StaticSaltedHasher, 30000> hasSigForIdCache GUARDED_BY(cs_cache); - mutable unordered_lru_cache hasSigForSessionCache GUARDED_BY(cs_cache); - mutable unordered_lru_cache hasSigForHashCache GUARDED_BY(cs_cache); + mutable Uint256LruHashMap hasSigForSessionCache GUARDED_BY(cs_cache); + mutable Uint256LruHashMap hasSigForHashCache GUARDED_BY(cs_cache); public: explicit CRecoveredSigsDb(bool fMemory, bool fWipe); @@ -165,7 +165,7 @@ class CSigningManager mutable Mutex cs_pending; // Incoming and not verified yet std::unordered_map>> pendingRecoveredSigs GUARDED_BY(cs_pending); - std::unordered_map, StaticSaltedHasher> pendingReconstructedRecoveredSigs GUARDED_BY(cs_pending); + Uint256HashMap> pendingReconstructedRecoveredSigs GUARDED_BY(cs_pending); FastRandomContext rnd GUARDED_BY(cs_pending); diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index ee33ecaf7c0d3..0ce382ce12601 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -1008,7 +1008,7 @@ void CSigSharesManager::CollectSigSharesToSendConcentrated(std::unordered_map proTxToNode; + Uint256HashMap proTxToNode; for (const auto& pnode : vNodes) { auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash(); if (verifiedProRegTxHash.IsNull()) { diff --git a/src/llmq/signing_shares.h b/src/llmq/signing_shares.h index 2a84a11628028..9ea596457cb6a 100644 --- a/src/llmq/signing_shares.h +++ b/src/llmq/signing_shares.h @@ -157,7 +157,7 @@ template class SigShareMap { private: - std::unordered_map, StaticSaltedHasher> internalMap; + Uint256HashMap> internalMap; public: bool Add(const SigShareKey& k, const T& v) @@ -384,7 +384,7 @@ class CSigSharesManager : public CRecoveredSigsListener Uint256HashMap signedSessions GUARDED_BY(cs); // stores time of last receivedSigShare. Used to detect timeouts - std::unordered_map timeSeenForSessions GUARDED_BY(cs); + Uint256HashMap timeSeenForSessions GUARDED_BY(cs); std::unordered_map nodeStates GUARDED_BY(cs); SigShareMap> sigSharesRequested GUARDED_BY(cs); diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index faf672b7346b2..622bd9dccd5d3 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -204,7 +204,7 @@ std::vector GetAllQuorumMembers(Consensus::LLMQType llmqTy bool reset_cache) { static RecursiveMutex cs_members; - static std::map, StaticSaltedHasher>> mapQuorumMembers GUARDED_BY(cs_members); + static std::map>> mapQuorumMembers GUARDED_BY(cs_members); static RecursiveMutex cs_indexed_members; static std::map, std::vector, StaticSaltedHasher>> mapIndexedQuorumMembers GUARDED_BY(cs_indexed_members); if (!IsQuorumTypeEnabled(llmqType, pQuorumBaseBlockIndex->pprev)) { @@ -969,13 +969,13 @@ void InitQuorumsCache(CacheType& cache, bool limit_by_connections) } } template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); -template void InitQuorumsCache, StaticSaltedHasher>>>(std::map, StaticSaltedHasher>>& cache, bool limit_by_connections); -template void InitQuorumsCache, StaticSaltedHasher, 0ul, 0ul>, std::less, std::allocator, StaticSaltedHasher, 0ul, 0ul>>>>>(std::map, StaticSaltedHasher, 0ul, 0ul>, std::less, std::allocator, StaticSaltedHasher, 0ul, 0ul>>>>&cache, bool limit_by_connections); +template void InitQuorumsCache>>>(std::map>>& cache, bool limit_by_connections); +template void InitQuorumsCache>, std::less, std::allocator>>>>>(std::map>, std::less, std::allocator>>>>&cache, bool limit_by_connections); template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); template void -InitQuorumsCache, StaticSaltedHasher>>>( - std::map, StaticSaltedHasher>>& cache, +InitQuorumsCache>>>( + std::map>>& cache, bool limit_by_connections); } // namespace utils } // namespace llmq diff --git a/src/net.cpp b/src/net.cpp index af6b302c9c28d..057795308faa4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3395,7 +3395,8 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman, if (!fNetworkActive || !m_masternode_thread_active || !mn_sync.IsBlockchainSynced()) continue; std::unordered_set connectedNodes; - std::unordered_map connectedProRegTxHashes; + // it maps protx hashes to fInboud flags + Uint256HashMap connectedProRegTxHashes; ForEachNode([&](const CNode* pnode) { connectedNodes.emplace(pnode->addr); if (auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash(); !verifiedProRegTxHash.IsNull()) { From 46a28e68019454c17358ce82a20cf09102b940ad Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 18 Sep 2025 19:24:21 +0700 Subject: [PATCH 6/7] fmt: apply clang-format --- src/chainlock/chainlock.h | 3 +-- src/chainlock/signing.h | 3 +-- src/evo/cbtx.cpp | 3 +-- src/evo/creditpool.cpp | 4 ++-- src/evo/creditpool.h | 2 +- src/evo/mnhftx.h | 2 +- src/instantsend/instantsend.h | 7 +++--- src/instantsend/signing.h | 3 +-- src/llmq/quorums.h | 3 ++- src/llmq/signing_shares.cpp | 5 ++--- src/llmq/signing_shares.h | 11 +++++----- src/llmq/utils.cpp | 41 +++++++++++++++++++++-------------- src/llmq/utils.h | 15 +++++++------ src/qt/sedsoVLyW | 0 src/saltedhasher.h | 2 +- 15 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 src/qt/sedsoVLyW diff --git a/src/chainlock/chainlock.h b/src/chainlock/chainlock.h index 7052605759857..549c13dbb3171 100644 --- a/src/chainlock/chainlock.h +++ b/src/chainlock/chainlock.h @@ -87,8 +87,7 @@ class CChainLocksHandler final : public chainlock::ChainLockSignerParent EXCLUSIVE_LOCKS_REQUIRED(!cs); chainlock::ChainLockSig GetBestChainLock() const EXCLUSIVE_LOCKS_REQUIRED(!cs); - void UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) override - EXCLUSIVE_LOCKS_REQUIRED(!cs); + void UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time) override EXCLUSIVE_LOCKS_REQUIRED(!cs); [[nodiscard]] MessageProcessingResult ProcessNewChainLock(NodeId from, const chainlock::ChainLockSig& clsig, const uint256& hash) override diff --git a/src/chainlock/signing.h b/src/chainlock/signing.h index c769ca3aa6ef2..ac9ee1fbada13 100644 --- a/src/chainlock/signing.h +++ b/src/chainlock/signing.h @@ -80,8 +80,7 @@ class ChainLockSigner final : public llmq::CRecoveredSigsListener [[nodiscard]] MessageProcessingResult HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig) override EXCLUSIVE_LOCKS_REQUIRED(!cs_signer); - [[nodiscard]] std::vector> Cleanup() - EXCLUSIVE_LOCKS_REQUIRED(!cs_signer); + [[nodiscard]] std::vector> Cleanup() EXCLUSIVE_LOCKS_REQUIRED(!cs_signer); private: [[nodiscard]] BlockTxs::mapped_type GetBlockTxs(const uint256& blockHash) diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index fe762b089b2f0..8954ba5f63cce 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -58,8 +58,7 @@ auto CachedGetQcHashesQcIndexedHashes(const CBlockIndex* pindexPrev, const llmq: static Mutex cs_cache; static std::map> quorums_cached GUARDED_BY(cs_cache); - static std::map>> qc_hashes_cached - GUARDED_BY(cs_cache); + static std::map>> qc_hashes_cached GUARDED_BY(cs_cache); static QcHashMap qcHashes_cached GUARDED_BY(cs_cache); static QcIndexedHashMap qcIndexedHashes_cached GUARDED_BY(cs_cache); diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index b4f89adae46a1..20ae214d32ffd 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -68,8 +68,8 @@ static std::optional GetCreditDataFromBlock(const gsl::n CreditPoolDataPerBlock blockData; static Mutex cache_mutex; - static Uint256LruHashMap block_data_cache GUARDED_BY( - cache_mutex){static_cast(Params().CreditPoolPeriodBlocks()) * 2}; + static Uint256LruHashMap block_data_cache GUARDED_BY(cache_mutex){ + static_cast(Params().CreditPoolPeriodBlocks()) * 2}; if (LOCK(cache_mutex); block_data_cache.get(block_index->GetBlockHash(), blockData)) { return blockData; } diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index 603503ae504ca..a78ec8a705065 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -111,7 +111,7 @@ class CCreditPoolManager private: static constexpr size_t CreditPoolCacheSize = 1000; Mutex cache_mutex; - Uint256LruHashMap creditPoolCache GUARDED_BY(cache_mutex) {CreditPoolCacheSize}; + Uint256LruHashMap creditPoolCache GUARDED_BY(cache_mutex){CreditPoolCacheSize}; CEvoDB& evoDb; diff --git a/src/evo/mnhftx.h b/src/evo/mnhftx.h index e92963e24c4fe..a016e6163489b 100644 --- a/src/evo/mnhftx.h +++ b/src/evo/mnhftx.h @@ -97,7 +97,7 @@ class CMNHFManager : public AbstractEHFManager static constexpr size_t MNHFCacheSize = 1000; Mutex cs_cache; // versionBit <-> height - Uint256LruHashMap mnhfCache GUARDED_BY(cs_cache) {MNHFCacheSize}; + Uint256LruHashMap mnhfCache GUARDED_BY(cs_cache){MNHFCacheSize}; public: explicit CMNHFManager(CEvoDB& evoDb); diff --git a/src/instantsend/instantsend.h b/src/instantsend/instantsend.h index a38967194d04a..735c3ddd4e94f 100644 --- a/src/instantsend/instantsend.h +++ b/src/instantsend/instantsend.h @@ -110,10 +110,9 @@ class CInstantSendManager final : public instantsend::InstantSendSignerParent instantsend::PendingState ProcessPendingInstantSendLocks() EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingLocks, !cs_pendingRetry); - Uint256HashSet ProcessPendingInstantSendLocks( - const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, - const Uint256HashMap>& pend, - std::vector>& peer_activity) + Uint256HashSet ProcessPendingInstantSendLocks(const Consensus::LLMQParams& llmq_params, int signOffset, bool ban, + const Uint256HashMap>& pend, + std::vector>& peer_activity) EXCLUSIVE_LOCKS_REQUIRED(!cs_nonLocked, !cs_pendingLocks, !cs_pendingRetry); MessageProcessingResult ProcessInstantSendLock(NodeId from, const uint256& hash, const instantsend::InstantSendLockPtr& islock) diff --git a/src/instantsend/signing.h b/src/instantsend/signing.h index c86481ef8f17b..3cf41a8431422 100644 --- a/src/instantsend/signing.h +++ b/src/instantsend/signing.h @@ -78,8 +78,7 @@ class InstantSendSigner final : public llmq::CRecoveredSigsListener void Start(); void Stop(); - void ClearInputsFromQueue(const Uint256HashSet& ids) - EXCLUSIVE_LOCKS_REQUIRED(!cs_input_requests); + void ClearInputsFromQueue(const Uint256HashSet& ids) EXCLUSIVE_LOCKS_REQUIRED(!cs_input_requests); void ClearLockFromQueue(const InstantSendLockPtr& islock) EXCLUSIVE_LOCKS_REQUIRED(!cs_creating); diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index 12d4b8efce88b..12354925a2a9e 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -250,7 +250,8 @@ class CQuorumManager mutable Mutex cs_map_quorums; mutable std::map> mapQuorumsCache GUARDED_BY(cs_map_quorums); mutable Mutex cs_scan_quorums; - mutable std::map>> scanQuorumsCache GUARDED_BY(cs_scan_quorums); + mutable std::map>> scanQuorumsCache + GUARDED_BY(cs_scan_quorums); mutable Mutex cs_cleanup; mutable std::map> cleanupQuorumsCache GUARDED_BY(cs_cleanup); diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index 0ce382ce12601..1911b15884378 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -1049,9 +1049,8 @@ void CSigSharesManager::CollectSigSharesToSendConcentrated(std::unordered_map>& sigSharesToAnnounce) +void CSigSharesManager::CollectSigSharesToAnnounce(const CConnman& connman, + std::unordered_map>& sigSharesToAnnounce) { AssertLockHeld(cs); diff --git a/src/llmq/signing_shares.h b/src/llmq/signing_shares.h index 9ea596457cb6a..bf26172190a0b 100644 --- a/src/llmq/signing_shares.h +++ b/src/llmq/signing_shares.h @@ -477,12 +477,13 @@ class CSigSharesManager : public CRecoveredSigsListener void BanNode(NodeId nodeId, PeerManager& peerman); bool SendMessages(CConnman& connman); - void CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) EXCLUSIVE_LOCKS_REQUIRED(cs); - void CollectSigSharesToSend(std::unordered_map>& sigSharesToSend) EXCLUSIVE_LOCKS_REQUIRED(cs); + void CollectSigSharesToRequest(std::unordered_map>& sigSharesToRequest) + EXCLUSIVE_LOCKS_REQUIRED(cs); + void CollectSigSharesToSend(std::unordered_map>& sigSharesToSend) + EXCLUSIVE_LOCKS_REQUIRED(cs); void CollectSigSharesToSendConcentrated(std::unordered_map>& sigSharesToSend, const std::vector& vNodes) EXCLUSIVE_LOCKS_REQUIRED(cs); - void CollectSigSharesToAnnounce( - const CConnman& connman, - std::unordered_map>& sigSharesToAnnounce) + void CollectSigSharesToAnnounce(const CConnman& connman, + std::unordered_map>& sigSharesToAnnounce) EXCLUSIVE_LOCKS_REQUIRED(cs); void SignPendingSigShares(const CConnman& connman, PeerManager& peerman); void WorkThreadMain(CConnman& connman, PeerManager& peerman); diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index 622bd9dccd5d3..c515cfe9ed0b1 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -204,7 +204,8 @@ std::vector GetAllQuorumMembers(Consensus::LLMQType llmqTy bool reset_cache) { static RecursiveMutex cs_members; - static std::map>> mapQuorumMembers GUARDED_BY(cs_members); + static std::map>> mapQuorumMembers GUARDED_BY( + cs_members); static RecursiveMutex cs_indexed_members; static std::map, std::vector, StaticSaltedHasher>> mapIndexedQuorumMembers GUARDED_BY(cs_indexed_members); if (!IsQuorumTypeEnabled(llmqType, pQuorumBaseBlockIndex->pprev)) { @@ -732,10 +733,10 @@ uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256 return proTxHash2; } -Uint256HashSet GetQuorumConnections( - const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, - const CSporkManager& sporkman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, - bool onlyOutbound) +Uint256HashSet GetQuorumConnections(const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, + CQuorumSnapshotManager& qsnapman, const CSporkManager& sporkman, + gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, + bool onlyOutbound) { if (IsAllMembersConnectedEnabled(llmqParams.type, sporkman)) { auto mns = GetAllQuorumMembers(llmqParams.type, dmnman, qsnapman, pQuorumBaseBlockIndex); @@ -758,9 +759,10 @@ Uint256HashSet GetQuorumConnections( return GetQuorumRelayMembers(llmqParams, dmnman, qsnapman, pQuorumBaseBlockIndex, forMember, onlyOutbound); } -Uint256HashSet GetQuorumRelayMembers( - const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, - gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound) +Uint256HashSet GetQuorumRelayMembers(const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, + CQuorumSnapshotManager& qsnapman, + gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, + bool onlyOutbound) { auto mns = GetAllQuorumMembers(llmqParams.type, dmnman, qsnapman, pQuorumBaseBlockIndex); Uint256HashSet result; @@ -968,14 +970,21 @@ void InitQuorumsCache(CacheType& cache, bool limit_by_connections) std::forward_as_tuple(limit_by_connections ? llmq.keepOldConnections : llmq.keepOldKeys)); } } -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); -template void InitQuorumsCache>>>(std::map>>& cache, bool limit_by_connections); -template void InitQuorumsCache>, std::less, std::allocator>>>>>(std::map>, std::less, std::allocator>>>>&cache, bool limit_by_connections); -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); -template void InitQuorumsCache>>(std::map>& cache, bool limit_by_connections); -template void -InitQuorumsCache>>>( - std::map>>& cache, +template void InitQuorumsCache>>( + std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>>( + std::map>>& cache, bool limit_by_connections); +template void InitQuorumsCache< + std::map>, std::less, + std::allocator>>>>>( + std::map>, std::less, + std::allocator>>>>& cache, bool limit_by_connections); +template void InitQuorumsCache>>( + std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>( + std::map>& cache, bool limit_by_connections); +template void InitQuorumsCache>>>( + std::map>>& cache, bool limit_by_connections); } // namespace utils } // namespace llmq diff --git a/src/llmq/utils.h b/src/llmq/utils.h index f09d84ae6dbc5..fd205ccbb6350 100644 --- a/src/llmq/utils.h +++ b/src/llmq/utils.h @@ -38,13 +38,14 @@ std::vector GetAllQuorumMembers(Consensus::LLMQType llmqTy bool reset_cache = false); uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2); -Uint256HashSet GetQuorumConnections( - const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, - const CSporkManager& sporkman, gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, - bool onlyOutbound); -Uint256HashSet GetQuorumRelayMembers( - const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, - gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound); +Uint256HashSet GetQuorumConnections(const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, + CQuorumSnapshotManager& qsnapman, const CSporkManager& sporkman, + gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, + bool onlyOutbound); +Uint256HashSet GetQuorumRelayMembers(const Consensus::LLMQParams& llmqParams, CDeterministicMNManager& dmnman, + CQuorumSnapshotManager& qsnapman, + gsl::not_null pQuorumBaseBlockIndex, const uint256& forMember, + bool onlyOutbound); std::set CalcDeterministicWatchConnections(Consensus::LLMQType llmqType, gsl::not_null pQuorumBaseBlockIndex, size_t memberCount, size_t connectionCount); bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, diff --git a/src/qt/sedsoVLyW b/src/qt/sedsoVLyW new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/saltedhasher.h b/src/saltedhasher.h index f7e075ffdd1ec..7cf4569f5b89a 100644 --- a/src/saltedhasher.h +++ b/src/saltedhasher.h @@ -83,7 +83,7 @@ using Uint256HashMap = std::unordered_map; using Uint256HashSet = std::unordered_set; -template +template class unordered_lru_cache; template using Uint256LruHashMap = unordered_lru_cache; From c461dcc5e62fade256b9f4b5e592804235d1adc8 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Sat, 20 Sep 2025 15:07:21 +0700 Subject: [PATCH 7/7] fix: review comments --- src/net.cpp | 3 +-- src/qt/sedsoVLyW | 0 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 src/qt/sedsoVLyW diff --git a/src/net.cpp b/src/net.cpp index 057795308faa4..f3fca77f592dd 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3395,8 +3395,7 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman, if (!fNetworkActive || !m_masternode_thread_active || !mn_sync.IsBlockchainSynced()) continue; std::unordered_set connectedNodes; - // it maps protx hashes to fInboud flags - Uint256HashMap connectedProRegTxHashes; + Uint256HashMap connectedProRegTxHashes; ForEachNode([&](const CNode* pnode) { connectedNodes.emplace(pnode->addr); if (auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash(); !verifiedProRegTxHash.IsNull()) { diff --git a/src/qt/sedsoVLyW b/src/qt/sedsoVLyW deleted file mode 100644 index e69de29bb2d1d..0000000000000