Skip to content

Commit f12a3b7

Browse files
committed
refactor: move RelayRecoveredSig() call out of CSigSharesManager
As ProcessRecoveredSig() triggers a NotifyRecoveredSig() notification, we can stick the RelayRecoveredSig() into CSigSharesManager and have the relay request processed through the notification interface instead, lets us finally drop CActiveMasternodeManager from CSigSharesManager.
1 parent 60401eb commit f12a3b7

File tree

7 files changed

+22
-12
lines changed

7 files changed

+22
-12
lines changed

src/llmq/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CDeterministicMNManager& d
3030
qman{std::make_unique<llmq::CQuorumManager>(*bls_worker, chainman.ActiveChainstate(), dmnman, *qdkgsman, evo_db,
3131
*quorum_block_processor, *qsnapman, mn_activeman, mn_sync, sporkman,
3232
unit_tests, wipe)},
33-
sigman{std::make_unique<llmq::CSigningManager>(mn_activeman, chainman.ActiveChainstate(), *qman, unit_tests, wipe)},
33+
sigman{std::make_unique<llmq::CSigningManager>(chainman.ActiveChainstate(), *qman, unit_tests, wipe)},
3434
clhandler{std::make_unique<llmq::CChainLocksHandler>(chainman.ActiveChainstate(), *qman, sporkman, mempool, mn_sync)},
3535
isman{std::make_unique<llmq::CInstantSendManager>(*clhandler, chainman.ActiveChainstate(), *qman, *sigman, sporkman,
3636
mempool, mn_sync, unit_tests, wipe)}

src/llmq/signing.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,8 @@ void CRecoveredSigsDb::CleanupOldVotes(int64_t maxAge)
332332

333333
//////////////////
334334

335-
CSigningManager::CSigningManager(const CActiveMasternodeManager* const mn_activeman, const CChainState& chainstate,
336-
const CQuorumManager& _qman, bool fMemory, bool fWipe) :
335+
CSigningManager::CSigningManager(const CChainState& chainstate, const CQuorumManager& _qman, bool fMemory, bool fWipe) :
337336
db(fMemory, fWipe),
338-
m_mn_activeman(mn_activeman),
339337
m_chainstate(chainstate),
340338
qman(_qman)
341339
{
@@ -615,10 +613,6 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
615613
db.WriteRecoveredSig(*recoveredSig);
616614
WITH_LOCK(cs_pending, pendingReconstructedRecoveredSigs.erase(recoveredSig->GetHash()));
617615

618-
if (m_mn_activeman != nullptr) {
619-
peerman.RelayRecoveredSig(recoveredSig->GetHash());
620-
}
621-
622616
auto listeners = WITH_LOCK(cs_listeners, return recoveredSigsListeners);
623617
for (auto& l : listeners) {
624618
peerman.PostProcessMessage(l->HandleNewRecoveredSig(*recoveredSig));

src/llmq/signing.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <string_view>
2424
#include <unordered_map>
2525

26-
class CActiveMasternodeManager;
2726
class CChainState;
2827
class CDataStream;
2928
class CDBBatch;
@@ -163,7 +162,6 @@ class CSigningManager
163162
private:
164163

165164
CRecoveredSigsDb db;
166-
const CActiveMasternodeManager* const m_mn_activeman;
167165
const CChainState& m_chainstate;
168166
const CQuorumManager& qman;
169167

@@ -180,8 +178,7 @@ class CSigningManager
180178
std::vector<CRecoveredSigsListener*> recoveredSigsListeners GUARDED_BY(cs_listeners);
181179

182180
public:
183-
CSigningManager(const CActiveMasternodeManager* const mn_activeman, const CChainState& chainstate,
184-
const CQuorumManager& _qman, bool fMemory, bool fWipe);
181+
CSigningManager(const CChainState& chainstate, const CQuorumManager& _qman, bool fMemory, bool fWipe);
185182

186183
bool AlreadyHave(const CInv& inv) const EXCLUSIVE_LOCKS_REQUIRED(!cs_pending);
187184
bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret) const;

src/llmq/signing_shares.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,11 @@ bool CSigSharesManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigning
949949
return true;
950950
}
951951

952+
void CSigSharesManager::NotifyRecoveredSig(const std::shared_ptr<const CRecoveredSig>& sig) const
953+
{
954+
m_peerman.RelayRecoveredSig(Assert(sig)->GetHash());
955+
}
956+
952957
void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, Uint256HashMap<CSigSharesInv>>& sigSharesToRequest)
953958
{
954959
AssertLockHeld(cs);

src/llmq/signing_shares.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ class CSigSharesManager : public CRecoveredSigsListener
445445
bool allowDiffMsgHashSigning = false)
446446
EXCLUSIVE_LOCKS_REQUIRED(!cs_pendingSigns);
447447

448+
void NotifyRecoveredSig(const std::shared_ptr<const CRecoveredSig>& sig) const;
449+
448450
private:
449451
// all of these return false when the currently processed message should be aborted (as each message actually contains multiple messages)
450452
bool ProcessMessageSigSesAnn(const CNode& pfrom, const CSigSesAnn& ann);

src/masternode/active/notificationinterface.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <governance/signing.h>
88
#include <llmq/ehf_signals.h>
9+
#include <llmq/signing_shares.h>
910
#include <masternode/active/context.h>
1011
#include <masternode/node.h>
1112

@@ -26,4 +27,9 @@ void ActiveNotificationInterface::UpdatedBlockTip(const CBlockIndex* pindexNew,
2627
m_active_ctx.gov_signer->UpdatedBlockTip(pindexNew);
2728
}
2829

30+
void ActiveNotificationInterface::NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig)
31+
{
32+
m_active_ctx.shareman->NotifyRecoveredSig(sig);
33+
}
34+
2935
std::unique_ptr<ActiveNotificationInterface> g_active_notification_interface;

src/masternode/active/notificationinterface.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
#include <validationinterface.h>
99

10+
#include <memory>
11+
1012
class CActiveMasternodeManager;
1113
struct ActiveContext;
14+
namespace llmq {
15+
class CRecoveredSig;
16+
} // namespace llmq
1217

1318
class ActiveNotificationInterface final : public CValidationInterface
1419
{
@@ -20,6 +25,7 @@ class ActiveNotificationInterface final : public CValidationInterface
2025

2126
protected:
2227
// CValidationInterface
28+
void NotifyRecoveredSig(const std::shared_ptr<const llmq::CRecoveredSig>& sig) override;
2329
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override;
2430

2531
private:

0 commit comments

Comments
 (0)