merge bitcoin#20646: refer to BIPs 339/155 in feature negotiation

This commit is contained in:
Kittywhiskers Van Gogh 2020-12-14 15:51:26 +01:00
parent 1d4f10a378
commit e109c0042a
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 4 additions and 2 deletions

View File

@ -487,6 +487,7 @@ public:
* messages, implying a preference to receive ADDRv2 instead of ADDR ones.
*/
std::atomic_bool m_wants_addrv2{false};
/** fSuccessfullyConnected is set to true on receiving VERACK from the peer. */
std::atomic_bool fSuccessfullyConnected{false};
// Setting fDisconnect to true will cause the node to be disconnected the
// next time DisconnectNodes() runs

View File

@ -3256,14 +3256,15 @@ void PeerManagerImpl::ProcessMessage(
return;
}
// BIP155 defines feature negotiation of addrv2 and sendaddrv2, which must happen
// between VERSION and VERACK.
if (msg_type == NetMsgType::SENDADDRV2) {
if (pfrom.GetCommonVersion() < ADDRV2_PROTO_VERSION) {
// Ignore previous implementations
return;
}
if (pfrom.fSuccessfullyConnected) {
// Disconnect peers that send SENDADDRV2 message after VERACK; this
// must be negotiated between VERSION and VERACK.
// Disconnect peers that send a SENDADDRV2 message after VERACK.
LogPrint(BCLog::NET_NETCONN, "sendaddrv2 received after verack from peer=%d; disconnecting\n", pfrom.GetId());
pfrom.fDisconnect = true;
return;