Introduce "qsendrecsigs" to indicate that plain recovered sigs should 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.
This commit is contained in:
Alexander Block 2019-03-21 07:47:02 +01:00 committed by GitHub
parent 60a91848a4
commit 12274e578a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 2 deletions

View File

@ -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);

View File

@ -817,8 +817,10 @@ public:
// 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();

View File

@ -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));
}
@ -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;

View File

@ -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";
@ -161,6 +162,7 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::MNGOVERNANCEOBJECTVOTE,
NetMsgType::GETMNLISTDIFF,
NetMsgType::MNLISTDIFF,
NetMsgType::QSENDRECSIGS,
NetMsgType::QFCOMMITMENT,
NetMsgType::QCONTRIB,
NetMsgType::QCOMPLAINT,

View File

@ -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;