Skip to content

server: Don't consider services before handshake.#3629

Merged
davecgh merged 3 commits intodecred:masterfrom
davecgh:peer_fields
Mar 3, 2026
Merged

server: Don't consider services before handshake.#3629
davecgh merged 3 commits intodecred:masterfrom
davecgh:peer_fields

Conversation

@davecgh
Copy link
Copy Markdown
Member

@davecgh davecgh commented Feb 28, 2026

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 addr and services fields used to change depending on the direction of the peer, but haven't for a long time. This renames them to include remote in their name to make it clear exactly what they refer to.

While here, remove a couple of old references to the services field that no longer apply.

@davecgh davecgh added this to the 2.2.0 milestone Feb 28, 2026
@davecgh davecgh changed the title peer: Rename a couple of internal fields. server: Don't consider services before handshake. Mar 2, 2026
@davecgh davecgh force-pushed the peer_fields branch 2 times, most recently from 45f515f to 819c91b Compare March 3, 2026 16:07
davecgh added 3 commits March 3, 2026 11:17
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.
@davecgh davecgh merged commit 2d9098e into decred:master Mar 3, 2026
33 checks passed
@davecgh davecgh deleted the peer_fields branch March 3, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants