Skip to content

Commit

Permalink
Introduce "qsendrecsigs" to indicate that plain recovered sigs should…
Browse files Browse the repository at this point in the history
… be sent (#2783)

* Introduce "qsendrecsigs" to indicate that plain recovered sigs should be sent

Full nodes, including masternodes, will send this message automatically.
Other node implementations (e.g. SPV) are usually not interested and would
not send this message.

* Use std::atomic<bool> instead of std::atomic_bool

Not related to this PR, but a small enough change to include it here as
well.
  • Loading branch information
codablock committed Mar 21, 2019
1 parent 60a9184 commit 12274e5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/llmq/quorums_signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,11 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re
}

CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig.GetHash());
g_connman->RelayInv(inv, LLMQS_PROTO_VERSION);
g_connman->ForEachNode([&](CNode* pnode) {
if (pnode->nVersion >= LLMQS_PROTO_VERSION && pnode->fSendRecSigs) {
pnode->PushInventory(inv);
}
});

for (auto& l : listeners) {
l->HandleNewRecoveredSig(recoveredSig);
Expand Down
4 changes: 3 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,10 @@ class CNode
// Whether a ping is requested.
std::atomic<bool> fPingQueued;

// 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};
std::atomic<bool> qwatch{false};

CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const std::string &addrNameIn = "", bool fInboundIn = false);
~CNode();
Expand Down
15 changes: 15 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
}

if (pfrom->nVersion >= LLMQS_PROTO_VERSION) {
// Tell our peer that we're interested in plain LLMQ recovered signatures.
// Otherwise the peer would only announce/send messages resulting from QRECSIG,
// e.g. InstantSend locks or ChainLocks. SPV nodes should not send this message
// as they are usually only interested in the higher level messages
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QSENDRECSIGS, true));
}

if (GetBoolArg("-watchquorums", llmq::DEFAULT_WATCH_QUORUMS)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QWATCH));
}
Expand Down Expand Up @@ -1763,6 +1771,13 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
}


else if (strCommand == NetMsgType::QSENDRECSIGS) {
bool b;
vRecv >> b;
pfrom->fSendRecSigs = b;
}


else if (strCommand == NetMsgType::INV)
{
std::vector<CInv> vInv;
Expand Down
2 changes: 2 additions & 0 deletions src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const char *MNGOVERNANCEOBJECT="govobj";
const char *MNGOVERNANCEOBJECTVOTE="govobjvote";
const char *GETMNLISTDIFF="getmnlistd";
const char *MNLISTDIFF="mnlistdiff";
const char *QSENDRECSIGS="qsendrecsigs";
const char *QFCOMMITMENT="qfcommit";
const char *QCONTRIB="qcontrib";
const char *QCOMPLAINT="qcomplaint";
Expand Down Expand Up @@ -161,6 +162,7 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::MNGOVERNANCEOBJECTVOTE,
NetMsgType::GETMNLISTDIFF,
NetMsgType::MNLISTDIFF,
NetMsgType::QSENDRECSIGS,
NetMsgType::QFCOMMITMENT,
NetMsgType::QCONTRIB,
NetMsgType::QCOMPLAINT,
Expand Down
1 change: 1 addition & 0 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ extern const char *MNGOVERNANCEOBJECT;
extern const char *MNGOVERNANCEOBJECTVOTE;
extern const char *GETMNLISTDIFF;
extern const char *MNLISTDIFF;
extern const char *QSENDRECSIGS;
extern const char *QFCOMMITMENT;
extern const char *QCONTRIB;
extern const char *QCOMPLAINT;
Expand Down

0 comments on commit 12274e5

Please sign in to comment.