Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: create helper function RelayRecoveredSig inside peerman #6423

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/llmq/signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,7 @@ void CSigningManager::ProcessRecoveredSig(const std::shared_ptr<const CRecovered
WITH_LOCK(cs_pending, pendingReconstructedRecoveredSigs.erase(recoveredSig->GetHash()));

if (m_mn_activeman != nullptr) {
CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig->GetHash());
connman.ForEachNode([&](const CNode* pnode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this change is soo good! Look to this one: 6149288

Maybe you can drop all usages of CConnman from llmq code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye! Awesome, didn't even realize I'd removed all usages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knst see: #6425 one more bites the dust!

if (pnode->fSendRecSigs) {
Assert(m_peerman)->PushInventory(pnode->GetId(), inv);
}
});
Assert(m_peerman)->RelayRecoveredSig(recoveredSig->GetHash());
}

auto listeners = WITH_LOCK(cs_listeners, return recoveredSigsListeners);
Expand Down
2 changes: 0 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,6 @@ class CNode
// If true, we will send him CoinJoin queue messages
std::atomic<bool> fSendDSQueue{false};

// If true, we will announce/send him plain recovered sigs (usually true for full nodes)
std::atomic<bool> fSendRecSigs{false};
// If true, we will send him all quorum related messages, even if he is not a member of our quorums
std::atomic<bool> qwatch{false};

Expand Down
16 changes: 15 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ struct Peer {
std::atomic<std::chrono::microseconds> m_ping_start{0us};
/** Whether a ping has been requested by the user */
std::atomic<bool> m_ping_queued{false};
/** Whether the peer has requested to receive llmq recovered signatures */
std::atomic<bool> m_wants_recsigs{false};

struct TxRelay {
mutable RecursiveMutex m_bloom_filter_mutex;
Expand Down Expand Up @@ -607,6 +609,7 @@ class PeerManagerImpl final : public PeerManager
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayTransaction(const uint256& txid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayRecoveredSig(const uint256& sigHash) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void SetBestHeight(int height) override { m_best_height = height; };
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message = "") override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
Expand Down Expand Up @@ -2339,6 +2342,17 @@ void PeerManagerImpl::RelayTransaction(const uint256& txid)
};
}

void PeerManagerImpl::RelayRecoveredSig(const uint256& sigHash)
{
const CInv inv{MSG_QUORUM_RECOVERED_SIG, sigHash};
LOCK(m_peer_mutex);
for (const auto& [_, peer] : m_peer_map) {
if (peer->m_wants_recsigs) {
PushInv(*peer, inv);
}
}
}

void PeerManagerImpl::RelayAddress(NodeId originator,
const CAddress& addr,
bool fReachable)
Expand Down Expand Up @@ -3948,7 +3962,7 @@ void PeerManagerImpl::ProcessMessage(
if (msg_type == NetMsgType::QSENDRECSIGS) {
bool b;
vRecv >> b;
pfrom.fSendRecSigs = b;
peer->m_wants_recsigs = b;
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
virtual void RelayTransaction(const uint256& txid)
EXCLUSIVE_LOCKS_REQUIRED(cs_main) = 0;

/** Relay recovered sigs to all interested peers */
virtual void RelayRecoveredSig(const uint256& sigHash) = 0;

/** Set the best height */
virtual void SetBestHeight(int height) = 0;

Expand Down
Loading