Skip to content

Commit

Permalink
fixup! Add p2p message "wtxidrelay"
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaftuar committed Feb 5, 2020
1 parent 61e2e97 commit c4a23a1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/net_processing.cpp
Expand Up @@ -2051,6 +2051,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
if (pfrom->fInbound)
PushNodeVersion(pfrom, connman, GetAdjustedTime());

if (nVersion >= WTXID_RELAY_VERSION) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::WTXIDRELAY));
}

connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERACK));

pfrom->nServices = nServices;
Expand Down Expand Up @@ -2187,10 +2191,20 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
}

pfrom->fSuccessfullyConnected = true;
return true;
}

// Feature negotiation of wtxidrelay should happen between VERSION and
// VERACK, to avoid relay problems from switching after a connection is up
if (strCommand == NetMsgType::WTXIDRELAY) {
if (pfrom->nVersion >= WTXID_RELAY_VERSION) {
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::WTXIDRELAY));
LOCK(cs_main);
if (!State(pfrom->GetId())->m_wtxid_relay) {
State(pfrom->GetId())->m_wtxid_relay = true;
g_wtxid_relay_peers++;
}
}
pfrom->fSuccessfullyConnected = true;
return true;
}

Expand Down Expand Up @@ -2255,15 +2269,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return true;
}

if (strCommand == NetMsgType::WTXIDRELAY && pfrom->nVersion >= WTXID_RELAY_VERSION) {
LOCK(cs_main);
if (!State(pfrom->GetId())->m_wtxid_relay) {
State(pfrom->GetId())->m_wtxid_relay = true;
g_wtxid_relay_peers++;
}
return true;
}

if (strCommand == NetMsgType::SENDHEADERS) {
LOCK(cs_main);
State(pfrom->GetId())->fPreferHeaders = true;
Expand Down

0 comments on commit c4a23a1

Please sign in to comment.