aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2020-01-30 10:10:50 -0500
committerSuhas Daftuar <sdaftuar@gmail.com>2020-07-19 02:10:41 -0400
commit46d78d47dea345329ba094310eec56ab00a02ddc (patch)
treebb811d9a5512988a7824f6d11c12ed508677b796 /src/net_processing.cpp
parent2d282e0cba9761574b6b43d134ca95f3052d7fd2 (diff)
downloadbitcoin-46d78d47dea345329ba094310eec56ab00a02ddc.tar.xz
Add p2p message "wtxidrelay"
When sent to and received from a given peer, enables using wtxid's for announcing and fetching transactions with that peer.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index f3b34957b1..ca94a1db11 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2342,6 +2342,10 @@ void ProcessMessage(
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;
@@ -2478,6 +2482,18 @@ void ProcessMessage(
return;
}
+ // Feature negotiation of wtxidrelay should happen between VERSION and
+ // VERACK, to avoid relay problems from switching after a connection is up
+ if (msg_type == NetMsgType::WTXIDRELAY) {
+ if (pfrom.nVersion >= WTXID_RELAY_VERSION) {
+ LOCK(cs_main);
+ if (!State(pfrom.GetId())->m_wtxid_relay) {
+ State(pfrom.GetId())->m_wtxid_relay = true;
+ }
+ }
+ return;
+ }
+
if (!pfrom.fSuccessfullyConnected) {
// Must have a verack message before anything else
LOCK(cs_main);