server: Don't consider services before handshake.#3629
Merged
davecgh merged 3 commits intodecred:masterfrom Mar 3, 2026
Merged
server: Don't consider services before handshake.#3629davecgh merged 3 commits intodecred:masterfrom
davecgh merged 3 commits intodecred:masterfrom
Conversation
This was referenced Feb 28, 2026
45f515f to
819c91b
Compare
jrick
approved these changes
Mar 3, 2026
The sync manager considers the services when the initial peer is created, but the remote services are not known until the handshake completes. This adds a channel that is closed when a verack is received in order to wait for the handshake to complete prior to creating the sync manager peer to ensure the remote services are known and populated. It also moves the code that adds the peer to the server to happen after the handshake as well since it relies on the sync manager. This was discovered by changes that will be in the next commit to no longer improperly assume the remote services before they're known.
The internal services field used to change depending on the direction of the peer, but that hasn't been the case for a long time. This renames the field to remoteServices to make it clear that it only refers to the service of the remote peer. While here, remove a couple of old references to the field that no longer apply and stop assuming the remove services before they are known.
The internal addr field used to change depending on the direction of the peer, but that hasn't been the case for a long time. This renames the field to remoteAddr to make it clear that it only refers to the address of the remote peer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This requires #3625.The peer code currently improperly assumes the remote services before they're known. However, correcting that alone would lead to incorrect behavior in the sync manager because it considers the services when the initial peer is created, but the remote services are not known until the handshake completes.
This adds a channel that is closed when a verack is received in order to wait for the handshake to complete prior to creating the sync manager peer to ensure the remote services are known and populated.
It also moves the code that adds the peer to the server to happen after the handshake as well since it relies on the sync manager.
This was discovered while making the changes in other commits in this PR.
Namely:
The internal
addrandservicesfields used to change depending on the direction of the peer, but haven't for a long time. This renames them to includeremotein their name to make it clear exactly what they refer to.While here, remove a couple of old references to the
servicesfield that no longer apply.