-
Notifications
You must be signed in to change notification settings - Fork 39.1k
p2p: send first addr self-announcement in separate message 🎄 #34146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5328,7 +5328,20 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros | |
| } | ||
| if (std::optional<CService> local_service = GetLocalAddrForPeer(node)) { | ||
| CAddress local_addr{*local_service, peer.m_our_services, Now<NodeSeconds>()}; | ||
| PushAddress(peer, local_addr); | ||
| if (peer.m_next_local_addr_send == 0us) { | ||
| // Send the initial self-announcement in its own message. This makes sure | ||
| // rate-limiting with limited start-tokens doesn't ignore it if the first | ||
| // message ends up containing multiple addresses. | ||
| std::vector<CAddress> self_announcement {local_addr}; | ||
| if (peer.m_wants_addrv2) { | ||
| MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new direct-send path bypasses the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that those two checks might still be needed to ensure the address we’re about to relay is valid and compatible with the peer, even if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but haven't had the time to investigate closer
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but haven't had the time to investigate closer |
||
| } else { | ||
| MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement)); | ||
| } | ||
| } else { | ||
| // All later self-announcements are sent together with the other addresses. | ||
| PushAddress(peer, local_addr); | ||
| } | ||
| } | ||
| peer.m_next_local_addr_send = current_time + m_rng.rand_exp_duration(AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
micro-nit: could drop space