aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-12-07 09:12:37 -0800
committerPieter Wuille <pieter@wuille.net>2020-12-08 09:40:10 -0800
commit1583498fb6781c01ca2f33c09319ed793964c574 (patch)
tree57683e6e79390368a173545f1b693467618c54d0 /src/net_processing.cpp
parentc5a89196602e43ebb1cdc9cd4f08d153419c13e1 (diff)
Send and require SENDADDRV2 before VERACK
See the corresponding BIP change: https://github.com/bitcoin/bips/pull/1043
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 667c5fa5a3..287f9c186c 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2362,8 +2362,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::WTXIDRELAY));
}
- m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
-
// Signal ADDRv2 support (BIP155).
if (greatest_common_version >= 70016) {
// BIP155 defines addrv2 and sendaddrv2 for all protocol versions, but some
@@ -2373,6 +2371,8 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDADDRV2));
}
+ m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
+
pfrom.nServices = nServices;
pfrom.SetAddrLocal(addrMe);
{
@@ -2541,6 +2541,17 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
return;
}
+ if (msg_type == NetMsgType::SENDADDRV2) {
+ if (pfrom.fSuccessfullyConnected) {
+ // Disconnect peers that send SENDADDRV2 message after VERACK; this
+ // must be negotiated between VERSION and VERACK.
+ pfrom.fDisconnect = true;
+ return;
+ }
+ pfrom.m_wants_addrv2 = true;
+ return;
+ }
+
if (!pfrom.fSuccessfullyConnected) {
LogPrint(BCLog::NET, "Unsupported message \"%s\" prior to verack from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
return;
@@ -2608,11 +2619,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
return;
}
- if (msg_type == NetMsgType::SENDADDRV2) {
- pfrom.m_wants_addrv2 = true;
- return;
- }
-
if (msg_type == NetMsgType::SENDHEADERS) {
LOCK(cs_main);
State(pfrom.GetId())->fPreferHeaders = true;