Skip to content
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

server: Use server peer in log statements. #3202

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Oct 28, 2023

This requires #3201.

This change a few cases that log the peer to use the server peer instead of the underlying peer from the peer package. This doesn't change the output in any way, but it is more consistent with the vast majority of other instances. It also preferable since it ensures consistent logging output if a custom stringer is ever implemented on server peers.

This renames the NewPeer method to PeerConnected to more clearly denote
its purpose.  It also renames some of the internal plumbing to match.
This renames the DonePeer method to PeerDisconnected to more clearly
denote its purpose.  It also renames some of the internal plumbing to
match.
Currently the sync manager maintains additional state per peer in an
internal struct that wraps a base/common peer as well as a mapping keyed
by that base/common peer.  The internal wrapped peer is then queried
each time it is needed.  This leads to code that is harder to reason
about and can fail to lookup the necessary state in some hard to hit
corner cases.

With that in mind, this modifies the sync manager semantics to instead
export the wrapped peer and require the caller to provide that wrapped
peer in all of its APIs directly.  The server then creates and stores
the wrapped peer instance at connection time and passes it to the sync
manager.

The end result is the code is easier to reason about and resolves the
aforementioned hard to hit corner cases since it is no longer possible
for the sync manager to ever have access to a peer without the
associated extra state.
This change a few cases that log the peer to use the server peer instead
of the underlying peer from the peer package.  This doesn't change the
output in any way, but it is more consistent with the vast majority of
other instances.  It also preferable since it ensures consistent logging
output if a custom stringer is ever implemented on server peers.
@davecgh davecgh added this to the 1.9.0 milestone Oct 28, 2023
@davecgh davecgh merged commit b60de60 into decred:master Oct 30, 2023
2 checks passed
@davecgh davecgh deleted the server_peer_stringer branch October 30, 2023 15:07
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.

5 participants