Skip to content

Commit e1e6714

Browse files
committed
doc: refer to BIPs 339/155 in feature negotiation
and add fSuccessfullyConnected doxygen documentation to clarify that it is set to true on VERACK
1 parent 384e090 commit e1e6714

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ class CNode
445445
* messages, implying a preference to receive ADDRv2 instead of ADDR ones.
446446
*/
447447
std::atomic_bool m_wants_addrv2{false};
448+
/** fSuccessfullyConnected is set to true on receiving VERACK from the peer. */
448449
std::atomic_bool fSuccessfullyConnected{false};
449450
// Setting fDisconnect to true will cause the node to be disconnected the
450451
// next time DisconnectNodes() runs

src/net_processing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,12 +2745,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
27452745
return;
27462746
}
27472747

2748-
// Feature negotiation of wtxidrelay must happen between VERSION and VERACK
2749-
// to avoid relay problems from switching after a connection is up.
2748+
// BIP339 defines feature negotiation of wtxidrelay, which must happen between
2749+
// VERSION and VERACK to avoid relay problems from switching after a connection is up.
27502750
if (msg_type == NetMsgType::WTXIDRELAY) {
27512751
if (pfrom.fSuccessfullyConnected) {
2752-
// Disconnect peers that send wtxidrelay message after VERACK; this
2753-
// must be negotiated between VERSION and VERACK.
2752+
// Disconnect peers that send a wtxidrelay message after VERACK.
27542753
LogPrint(BCLog::NET, "wtxidrelay received after verack from peer=%d; disconnecting\n", pfrom.GetId());
27552754
pfrom.fDisconnect = true;
27562755
return;
@@ -2769,10 +2768,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
27692768
return;
27702769
}
27712770

2771+
// BIP155 defines feature negotiation of addrv2 and sendaddrv2, which must happen
2772+
// between VERSION and VERACK.
27722773
if (msg_type == NetMsgType::SENDADDRV2) {
27732774
if (pfrom.fSuccessfullyConnected) {
2774-
// Disconnect peers that send SENDADDRV2 message after VERACK; this
2775-
// must be negotiated between VERSION and VERACK.
2775+
// Disconnect peers that send a SENDADDRV2 message after VERACK.
27762776
LogPrint(BCLog::NET, "sendaddrv2 received after verack from peer=%d; disconnecting\n", pfrom.GetId());
27772777
pfrom.fDisconnect = true;
27782778
return;

0 commit comments

Comments
 (0)