Skip to content

Commit 119d7a9

Browse files
committed
refactor: static class members to static anonymous functions of CSigningSharesManager
They have no external calls outside of signing_shares
1 parent 02f7d80 commit 119d7a9

2 files changed

Lines changed: 23 additions & 28 deletions

File tree

src/llmq/signing_shares.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ bool CSigSharesManager::ProcessMessageSigSesAnn(const CNode& pfrom, const CSigSe
234234
return true;
235235
}
236236

237-
bool CSigSharesManager::VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv)
237+
static bool VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv)
238238
{
239239
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
240240
return llmq_params_opt.has_value() && (inv.inv.size() == size_t(llmq_params_opt->size));
@@ -303,6 +303,28 @@ static bool PreVerifySigShareQuorum(const CActiveMasternodeManager& mn_activeman
303303
return true;
304304
}
305305

306+
// Ban node if PreVerifyBatchedSigShares failed
307+
bool PreVerifyBatchedSigShares(const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares)
308+
{
309+
std::unordered_set<uint16_t> dupMembers;
310+
311+
for (const auto& [quorumMember, _] : batchedSigShares.sigShares) {
312+
if (!dupMembers.emplace(quorumMember).second) {
313+
return false;
314+
}
315+
316+
if (quorumMember >= session.quorum->members.size()) {
317+
LogPrint(BCLog::LLMQ_SIGS, "%s -- quorumMember out of bounds\n", __func__);
318+
return false;
319+
}
320+
if (!session.quorum->qc->validMembers[quorumMember]) {
321+
LogPrint(BCLog::LLMQ_SIGS, "%s -- quorumMember not valid\n", __func__);
322+
return false;
323+
}
324+
}
325+
return true;
326+
}
327+
306328
bool CSigSharesManager::ProcessMessageBatchedSigShares(const CNode& pfrom, const CBatchedSigShares& batchedSigShares)
307329
{
308330
CSigSharesNodeState::SessionInfo sessionInfo;
@@ -409,29 +431,6 @@ bool CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& s
409431
return true;
410432
}
411433

412-
// Ban node if PreVerifyBatchedSigShares failed
413-
bool CSigSharesManager::PreVerifyBatchedSigShares(const CSigSharesNodeState::SessionInfo& session,
414-
const CBatchedSigShares& batchedSigShares)
415-
{
416-
std::unordered_set<uint16_t> dupMembers;
417-
418-
for (const auto& [quorumMember, _] : batchedSigShares.sigShares) {
419-
if (!dupMembers.emplace(quorumMember).second) {
420-
return false;
421-
}
422-
423-
if (quorumMember >= session.quorum->members.size()) {
424-
LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::%s -- quorumMember out of bounds\n", __func__);
425-
return false;
426-
}
427-
if (!session.quorum->qc->validMembers[quorumMember]) {
428-
LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::%s -- quorumMember not valid\n", __func__);
429-
return false;
430-
}
431-
}
432-
return true;
433-
}
434-
435434
bool CSigSharesManager::CollectPendingSigSharesToVerify(
436435
size_t maxUniqueSessions, std::unordered_map<NodeId, std::vector<CSigShare>>& retSigShares,
437436
std::unordered_map<std::pair<Consensus::LLMQType, uint256>, CQuorumCPtr, StaticSaltedHasher>& retQuorums)

src/llmq/signing_shares.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,6 @@ class CSigSharesManager : public llmq::CRecoveredSigsListener
469469
EXCLUSIVE_LOCKS_REQUIRED(!cs);
470470

471471
private:
472-
static bool VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv);
473-
static bool PreVerifyBatchedSigShares(const CSigSharesNodeState::SessionInfo& session,
474-
const CBatchedSigShares& batchedSigShares);
475-
476472
[[nodiscard]] std::shared_ptr<CRecoveredSig> ProcessSigShare(const CSigShare& sigShare, const CQuorumCPtr& quorum)
477473
EXCLUSIVE_LOCKS_REQUIRED(!cs);
478474
[[nodiscard]] std::shared_ptr<CRecoveredSig> TryRecoverSig(const CQuorum& quorum, const uint256& id,

0 commit comments

Comments
 (0)