@@ -65,10 +65,9 @@ std::string CSigSharesInv::ToString() const
65
65
return str;
66
66
}
67
67
68
- void CSigSharesInv::Init (Consensus::LLMQType _llmqType )
68
+ void CSigSharesInv::Init (size_t size )
69
69
{
70
- size_t llmqSize = (size_t )(Params ().GetConsensus ().llmqs .at (_llmqType).size );
71
- inv.resize (llmqSize, false );
70
+ inv.resize (size, false );
72
71
}
73
72
74
73
bool CSigSharesInv::IsSet (uint16_t quorumMember) const
@@ -83,27 +82,30 @@ void CSigSharesInv::Set(uint16_t quorumMember, bool v)
83
82
inv[quorumMember] = v;
84
83
}
85
84
86
- CSigSharesInv CBatchedSigShares::ToInv (Consensus::LLMQType llmqType ) const
85
+ std::string CBatchedSigShares::ToInvString ( ) const
87
86
{
88
87
CSigSharesInv inv;
89
- inv.Init (llmqType);
88
+ // we use 400 here no matter what the real size is. We don't really care about that size as we just want to call ToString()
89
+ inv.Init (400 );
90
90
for (size_t i = 0 ; i < sigShares.size (); i++) {
91
91
inv.inv [sigShares[i].first ] = true ;
92
92
}
93
- return inv;
93
+ return inv. ToString () ;
94
94
}
95
95
96
96
template <typename T>
97
97
static void InitSession (CSigSharesNodeState::Session& s, const uint256& signHash, T& from)
98
98
{
99
+ const auto & params = Params ().GetConsensus ().llmqs .at ((Consensus::LLMQType)from.llmqType );
100
+
99
101
s.llmqType = (Consensus::LLMQType)from.llmqType ;
100
102
s.quorumHash = from.quorumHash ;
101
103
s.id = from.id ;
102
104
s.msgHash = from.msgHash ;
103
105
s.signHash = signHash;
104
- s.announced .Init ((Consensus::LLMQType)from. llmqType );
105
- s.requested .Init ((Consensus::LLMQType)from. llmqType );
106
- s.knows .Init ((Consensus::LLMQType)from. llmqType );
106
+ s.announced .Init ((size_t )params. size );
107
+ s.requested .Init ((size_t )params. size );
108
+ s.knows .Init ((size_t )params. size );
107
109
}
108
110
109
111
CSigSharesNodeState::Session& CSigSharesNodeState::GetOrCreateSessionFromShare (const llmq::CSigShare& sigShare)
@@ -443,7 +445,7 @@ bool CSigSharesManager::ProcessMessageBatchedSigShares(CNode* pfrom, const CBatc
443
445
}
444
446
445
447
LogPrint (" llmq" , " CSigSharesManager::%s -- signHash=%s, shares=%d, new=%d, inv={%s}, node=%d\n " , __func__,
446
- sessionInfo.signHash .ToString (), batchedSigShares.sigShares .size (), sigShares.size (), batchedSigShares.ToInv (sessionInfo. llmqType ). ToString (), pfrom->id );
448
+ sessionInfo.signHash .ToString (), batchedSigShares.sigShares .size (), sigShares.size (), batchedSigShares.ToInvString (), pfrom->id );
447
449
448
450
if (sigShares.empty ()) {
449
451
return true ;
@@ -871,7 +873,8 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
871
873
}
872
874
auto & inv = (*invMap)[signHash];
873
875
if (inv.inv .empty ()) {
874
- inv.Init (session.llmqType );
876
+ const auto & params = Params ().GetConsensus ().llmqs .at ((Consensus::LLMQType)session.llmqType );
877
+ inv.Init ((size_t )params.size );
875
878
}
876
879
inv.inv [k.second ] = true ;
877
880
@@ -982,7 +985,8 @@ void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, st
982
985
983
986
auto & inv = sigSharesToAnnounce[nodeId][signHash];
984
987
if (inv.inv .empty ()) {
985
- inv.Init ((Consensus::LLMQType)sigShare->llmqType );
988
+ const auto & params = Params ().GetConsensus ().llmqs .at ((Consensus::LLMQType)sigShare->llmqType );
989
+ inv.Init ((size_t )params.size );
986
990
}
987
991
inv.inv [quorumMember] = true ;
988
992
session.knows .inv [quorumMember] = true ;
@@ -1101,14 +1105,8 @@ bool CSigSharesManager::SendMessages()
1101
1105
std::vector<CBatchedSigShares> msgs;
1102
1106
for (auto & p : jt->second ) {
1103
1107
assert (!p.second .sigShares .empty ());
1104
- if (LogAcceptCategory (" llmq" )) {
1105
- LOCK (cs);
1106
- auto session = nodeStates[pnode->id ].GetSessionBySignHash (p.first );
1107
- assert (session);
1108
- LogPrint (" llmq" , " CSigSharesManager::SendMessages -- QBSIGSHARES signHash=%s, inv={%s}, node=%d\n " ,
1109
- p.first .ToString (), p.second .ToInv (session->llmqType ).ToString (), pnode->id );
1110
- }
1111
-
1108
+ LogPrint (" llmq" , " CSigSharesManager::SendMessages -- QBSIGSHARES signHash=%s, inv={%s}, node=%d\n " ,
1109
+ p.first .ToString (), p.second .ToInvString (), pnode->id );
1112
1110
if (totalSigsCount + p.second .sigShares .size () > MAX_MSGS_TOTAL_BATCHED_SIGS) {
1113
1111
g_connman->PushMessage (pnode, msgMaker.Make (NetMsgType::QBSIGSHARES, msgs), false );
1114
1112
msgs.clear ();
0 commit comments