@@ -386,7 +386,7 @@ bool CSigSharesManager::PreVerifyBatchedSigShares(NodeId nodeId, const CBatchedS
386
386
void CSigSharesManager::CollectPendingSigSharesToVerify (
387
387
size_t maxUniqueSessions,
388
388
std::unordered_map<NodeId, std::vector<CSigShare>>& retSigShares,
389
- std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr>& retQuorums)
389
+ std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher >& retQuorums)
390
390
{
391
391
{
392
392
LOCK (cs);
@@ -400,7 +400,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
400
400
// invalid, making batch verification fail and revert to per-share verification, which in turn would slow down
401
401
// the whole verification process
402
402
403
- std::unordered_set<std::pair<NodeId, uint256>> uniqueSignHashes;
403
+ std::unordered_set<std::pair<NodeId, uint256>, StaticSaltedHasher > uniqueSignHashes;
404
404
CLLMQUtils::IterateNodesRandom (nodeStates, [&]() {
405
405
return uniqueSignHashes.size () < maxUniqueSessions;
406
406
}, [&](NodeId nodeId, CSigSharesNodeState& ns) {
@@ -448,7 +448,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
448
448
bool CSigSharesManager::ProcessPendingSigShares (CConnman& connman)
449
449
{
450
450
std::unordered_map<NodeId, std::vector<CSigShare>> sigSharesByNodes;
451
- std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr> quorums;
451
+ std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher > quorums;
452
452
453
453
CollectPendingSigSharesToVerify (32 , sigSharesByNodes, quorums);
454
454
if (sigSharesByNodes.empty ()) {
@@ -517,7 +517,10 @@ bool CSigSharesManager::ProcessPendingSigShares(CConnman& connman)
517
517
}
518
518
519
519
// It's ensured that no duplicates are passed to this method
520
- void CSigSharesManager::ProcessPendingSigSharesFromNode (NodeId nodeId, const std::vector<CSigShare>& sigShares, const std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr>& quorums, CConnman& connman)
520
+ void CSigSharesManager::ProcessPendingSigSharesFromNode (NodeId nodeId,
521
+ const std::vector<CSigShare>& sigShares,
522
+ const std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher>& quorums,
523
+ CConnman& connman)
521
524
{
522
525
auto & nodeState = nodeStates[nodeId];
523
526
@@ -668,11 +671,9 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
668
671
}
669
672
670
673
// cs must be held
671
- void CSigSharesManager::CollectSigSharesToRequest (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>>& sigSharesToRequest)
674
+ void CSigSharesManager::CollectSigSharesToRequest (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >>& sigSharesToRequest)
672
675
{
673
676
int64_t now = GetTimeMillis ();
674
- std::unordered_map<SigShareKey, std::vector<NodeId>> nodesBySigShares;
675
-
676
677
const size_t maxRequestsForNode = 32 ;
677
678
678
679
// avoid requesting from same nodes all the time
@@ -703,7 +704,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
703
704
return false ;
704
705
});
705
706
706
- std::unordered_map<uint256, CSigSharesInv> * invMap = nullptr ;
707
+ decltype (sigSharesToRequest. begin ()-> second ) * invMap = nullptr ;
707
708
708
709
for (auto & p2 : nodeState.sessions ) {
709
710
auto & signHash = p2.first ;
@@ -764,7 +765,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
764
765
}
765
766
766
767
// cs must be held
767
- void CSigSharesManager::CollectSigSharesToSend (std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares>>& sigSharesToSend)
768
+ void CSigSharesManager::CollectSigSharesToSend (std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher >>& sigSharesToSend)
768
769
{
769
770
for (auto & p : nodeStates) {
770
771
auto nodeId = p.first ;
@@ -774,7 +775,7 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
774
775
continue ;
775
776
}
776
777
777
- std::unordered_map<uint256, CBatchedSigShares> * sigSharesToSend2 = nullptr ;
778
+ decltype (sigSharesToSend. begin ()-> second ) * sigSharesToSend2 = nullptr ;
778
779
779
780
for (auto & p2 : nodeState.sessions ) {
780
781
auto & signHash = p2.first ;
@@ -821,9 +822,9 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
821
822
}
822
823
823
824
// cs must be held
824
- void CSigSharesManager::CollectSigSharesToAnnounce (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>>& sigSharesToAnnounce)
825
+ void CSigSharesManager::CollectSigSharesToAnnounce (std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >>& sigSharesToAnnounce)
825
826
{
826
- std::unordered_set<std::pair<Consensus::LLMQType, uint256>> quorumNodesPrepared;
827
+ std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher > quorumNodesPrepared;
827
828
828
829
this ->sigSharesToAnnounce .ForEach ([&](const SigShareKey& sigShareKey, bool ) {
829
830
auto & signHash = sigShareKey.first ;
@@ -890,9 +891,9 @@ bool CSigSharesManager::SendMessages()
890
891
nodesByAddress.emplace (pnode->addr , pnode->id );
891
892
});
892
893
893
- std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>> sigSharesToRequest;
894
- std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares>> sigSharesToSend;
895
- std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv>> sigSharesToAnnounce;
894
+ std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >> sigSharesToRequest;
895
+ std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher >> sigSharesToSend;
896
+ std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher >> sigSharesToAnnounce;
896
897
897
898
{
898
899
LOCK (cs);
@@ -956,13 +957,13 @@ void CSigSharesManager::Cleanup()
956
957
return ;
957
958
}
958
959
959
- std::unordered_set<std::pair<Consensus::LLMQType, uint256>> quorumsToCheck;
960
+ std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher > quorumsToCheck;
960
961
961
962
{
962
963
LOCK (cs);
963
964
964
965
// Remove sessions which were succesfully recovered
965
- std::unordered_set<uint256> doneSessions;
966
+ std::unordered_set<uint256, StaticSaltedHasher > doneSessions;
966
967
sigShares.ForEach ([&](const SigShareKey& k, const CSigShare& sigShare) {
967
968
if (doneSessions.count (sigShare.GetSignHash ())) {
968
969
return ;
@@ -976,7 +977,7 @@ void CSigSharesManager::Cleanup()
976
977
}
977
978
978
979
// Remove sessions which timed out
979
- std::unordered_set<uint256> timeoutSessions;
980
+ std::unordered_set<uint256, StaticSaltedHasher > timeoutSessions;
980
981
for (auto & p : timeSeenForSessions) {
981
982
auto & signHash = p.first ;
982
983
int64_t firstSeenTime = p.second .first ;
@@ -1020,7 +1021,7 @@ void CSigSharesManager::Cleanup()
1020
1021
{
1021
1022
// Now delete sessions which are for inactive quorums
1022
1023
LOCK (cs);
1023
- std::unordered_set<uint256> inactiveQuorumSessions;
1024
+ std::unordered_set<uint256, StaticSaltedHasher > inactiveQuorumSessions;
1024
1025
sigShares.ForEach ([&](const SigShareKey& k, const CSigShare& sigShare) {
1025
1026
if (quorumsToCheck.count (std::make_pair ((Consensus::LLMQType)sigShare.llmqType , sigShare.quorumHash ))) {
1026
1027
inactiveQuorumSessions.emplace (sigShare.GetSignHash ());
0 commit comments