aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Naumenko <naumenko.gs@gmail.com>2021-12-17 13:32:16 +0200
committerGleb Naumenko <naumenko.gs@gmail.com>2022-10-17 12:35:44 +0300
commitf63f1d3f4bdef2923a8395473ca59e4763769bd7 (patch)
tree09819b0cdd71f05431816608dd3f8267ea2ddd77
parent88d326c8e3796b9685c141fa50628615d3e43a38 (diff)
p2p: clear txreconciliation state for non-wtxid peers
We optimistically pre-register a peer for txreconciliations upon sending txreconciliation support announcement. But if, at VERACK, we realize that the peer never sent WTXIDRELAY message, we should unregister the peer from txreconciliations, because txreconciliations rely on wtxids.
-rw-r--r--src/net_processing.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 350187bdda..c87b0e7cd2 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3414,6 +3414,16 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// they may wish to request compact blocks from us
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, /*high_bandwidth=*/false, /*version=*/CMPCTBLOCKS_VERSION));
}
+
+ if (m_txreconciliation) {
+ if (!peer->m_wtxid_relay || !m_txreconciliation->IsPeerRegistered(pfrom.GetId())) {
+ // We could have optimistically pre-registered/registered the peer. In that case,
+ // we should forget about the reconciliation state here if this wasn't followed
+ // by WTXIDRELAY (since WTXIDRELAY can't be announced later).
+ m_txreconciliation->ForgetPeer(pfrom.GetId());
+ }
+ }
+
pfrom.fSuccessfullyConnected = true;
return;
}