@@ -380,7 +380,7 @@ bool CSigSharesManager::PreVerifyBatchedSigShares(NodeId nodeId, const CBatchedS
380
380
void CSigSharesManager::CollectPendingSigSharesToVerify (
381
381
size_t maxUniqueSessions,
382
382
std::unordered_map<NodeId, std::vector<CSigShare>>& retSigShares,
383
- std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr>& retQuorums)
383
+ std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher >& retQuorums)
384
384
{
385
385
{
386
386
LOCK (cs);
@@ -394,7 +394,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
394
394
// invalid, making batch verification fail and revert to per-share verification, which in turn would slow down
395
395
// the whole verification process
396
396
397
- std::unordered_set<std::pair<NodeId, uint256>> uniqueSignHashes;
397
+ std::unordered_set<std::pair<NodeId, uint256>, StaticSaltedHasher > uniqueSignHashes;
398
398
llmq::utils::IterateNodesRandom (nodeStates, [&]() { return uniqueSignHashes.size () < maxUniqueSessions; }, [&](NodeId nodeId, CSigSharesNodeState& ns) {
399
399
if (ns.pendingIncomingSigShares .Empty ()) {
400
400
return false ;
@@ -439,7 +439,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
439
439
bool CSigSharesManager::ProcessPendingSigShares (CConnman& connman)
440
440
{
441
441
std::unordered_map<NodeId, std::vector<CSigShare>> sigSharesByNodes;
442
- std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr> quorums;
442
+ std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher > quorums;
443
443
444
444
CollectPendingSigSharesToVerify (32 , sigSharesByNodes, quorums);
445
445
if (sigSharesByNodes.empty ()) {
@@ -508,7 +508,10 @@ bool CSigSharesManager::ProcessPendingSigShares(CConnman& connman)
508
508
}
509
509
510
510
// It's ensured that no duplicates are passed to this method
511
- void CSigSharesManager::ProcessPendingSigSharesFromNode (NodeId nodeId, const std::vector<CSigShare>& sigShares, const std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr>& quorums, CConnman& connman)
511
+ void CSigSharesManager::ProcessPendingSigSharesFromNode (NodeId nodeId,
512
+ const std::vector<CSigShare>& sigShares,
513
+ const std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher>& quorums,
514
+ CConnman& connman)
512
515
{
513
516
LOCK (cs);
514
517
auto & nodeState = nodeStates[nodeId];
@@ -660,11 +663,9 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
660
663
}
661
664
662
665
// cs must be held
663
- void CSigSharesManager::CollectSigSharesToRequest (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>>& sigSharesToRequest)
666
+ void CSigSharesManager::CollectSigSharesToRequest (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >>& sigSharesToRequest)
664
667
{
665
668
int64_t now = GetTimeMillis ();
666
- std::unordered_map<SigShareKey, std::vector<NodeId>> nodesBySigShares;
667
-
668
669
const size_t maxRequestsForNode = 32 ;
669
670
670
671
// avoid requesting from same nodes all the time
@@ -695,7 +696,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
695
696
return false ;
696
697
});
697
698
698
- std::unordered_map<uint256, CSigSharesInv> * invMap = nullptr ;
699
+ decltype (sigSharesToRequest. begin ()-> second ) * invMap = nullptr ;
699
700
700
701
for (auto & p2 : nodeState.sessions ) {
701
702
auto & signHash = p2.first ;
@@ -756,7 +757,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
756
757
}
757
758
758
759
// cs must be held
759
- void CSigSharesManager::CollectSigSharesToSend (std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares>>& sigSharesToSend)
760
+ void CSigSharesManager::CollectSigSharesToSend (std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher >>& sigSharesToSend)
760
761
{
761
762
for (auto & p : nodeStates) {
762
763
auto nodeId = p.first ;
@@ -766,7 +767,7 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
766
767
continue ;
767
768
}
768
769
769
- std::unordered_map<uint256, CBatchedSigShares> * sigSharesToSend2 = nullptr ;
770
+ decltype (sigSharesToSend. begin ()-> second ) * sigSharesToSend2 = nullptr ;
770
771
771
772
for (auto & p2 : nodeState.sessions ) {
772
773
auto & signHash = p2.first ;
@@ -813,9 +814,9 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
813
814
}
814
815
815
816
// cs must be held
816
- void CSigSharesManager::CollectSigSharesToAnnounce (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>>& sigSharesToAnnounce)
817
+ void CSigSharesManager::CollectSigSharesToAnnounce (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >>& sigSharesToAnnounce)
817
818
{
818
- std::unordered_set<std::pair<Consensus::LLMQType, uint256>> quorumNodesPrepared;
819
+ std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher > quorumNodesPrepared;
819
820
820
821
this ->sigSharesToAnnounce .ForEach ([&](const SigShareKey& sigShareKey, bool ) {
821
822
auto & signHash = sigShareKey.first ;
@@ -883,9 +884,9 @@ bool CSigSharesManager::SendMessages()
883
884
nodesByAddress.emplace (pnode->addr , pnode->GetId ());
884
885
});
885
886
886
- std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>> sigSharesToRequest;
887
- std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares>> sigSharesToSend;
888
- std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>> sigSharesToAnnounce;
887
+ std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >> sigSharesToRequest;
888
+ std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher >> sigSharesToSend;
889
+ std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >> sigSharesToAnnounce;
889
890
890
891
{
891
892
LOCK (cs);
@@ -945,13 +946,13 @@ void CSigSharesManager::Cleanup()
945
946
return ;
946
947
}
947
948
948
- std::unordered_set<std::pair<Consensus::LLMQType, uint256>> quorumsToCheck;
949
+ std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher > quorumsToCheck;
949
950
950
951
{
951
952
LOCK (cs);
952
953
953
954
// Remove sessions which were successfully recovered
954
- std::unordered_set<uint256> doneSessions;
955
+ std::unordered_set<uint256, StaticSaltedHasher > doneSessions;
955
956
sigShares.ForEach ([&](const SigShareKey& k, const CSigShare& sigShare) {
956
957
if (doneSessions.count (sigShare.GetSignHash ())) {
957
958
return ;
@@ -965,7 +966,7 @@ void CSigSharesManager::Cleanup()
965
966
}
966
967
967
968
// Remove sessions which timed out
968
- std::unordered_set<uint256> timeoutSessions;
969
+ std::unordered_set<uint256, StaticSaltedHasher > timeoutSessions;
969
970
for (auto & p : timeSeenForSessions) {
970
971
auto & signHash = p.first ;
971
972
int64_t firstSeenTime = p.second .first ;
@@ -1009,7 +1010,7 @@ void CSigSharesManager::Cleanup()
1009
1010
{
1010
1011
// Now delete sessions which are for inactive quorums
1011
1012
LOCK (cs);
1012
- std::unordered_set<uint256> inactiveQuorumSessions;
1013
+ std::unordered_set<uint256, StaticSaltedHasher > inactiveQuorumSessions;
1013
1014
sigShares.ForEach ([&](const SigShareKey& k, const CSigShare& sigShare) {
1014
1015
if (quorumsToCheck.count (std::make_pair ((Consensus::LLMQType)sigShare.llmqType , sigShare.quorumHash ))) {
1015
1016
inactiveQuorumSessions.emplace (sigShare.GetSignHash ());
0 commit comments