-
Notifications
You must be signed in to change notification settings - Fork 957
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
refactor(swarm)!: deprecate PollParameters
where possible
#3153
Conversation
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.
Two comments. Otherwise this looks great to me.
|
||
/// Utility struct for tracking the external addresses of a [`Swarm`](crate::Swarm). | ||
#[derive(Debug, Default, Clone)] | ||
pub struct ExternalAddresses { |
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.
pub struct ExternalAddresses { | |
pub struct ExternalAddressTracker { |
Not a strong opinion, though this would imply that one has to actively interact / pass-events with/to it.
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.
I am not convinced that this is a better name. Can you elaborate what you don't like about the current one? :)
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.
The name ExternalAddresses
does not imply to me as a user, that I need to pass the FromSwarm
events into it. That said, I think ExternalAddresses
is just fine.
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.
I would argue that this is only something a user needs to learn once and quite obvious from the implementation.
Most of the time, this name should convey that it holds the external addresses and only every so often, you need to understand how it works so I optimised for the common bit :)
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
PollParameters
where possiblePollParameters
where possible
PollParameters
where possiblePollParameters
where possible
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
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.
Solid work. Thanks!
|
||
/// Utility struct for tracking the external addresses of a [`Swarm`](crate::Swarm). | ||
#[derive(Debug, Default, Clone)] | ||
pub struct ExternalAddresses { |
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.
The name ExternalAddresses
does not imply to me as a user, that I need to pass the FromSwarm
events into it. That said, I think ExternalAddresses
is just fine.
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.
LGTM
) This patch deprecates 3 out of 4 functions on `PollParameters`: - `local_peer_id` - `listened_addresses` - `external_addresses` The addresses can be obtained by inspecting the `FromSwarm` event. To make this easier, we introduce two utility structs in `libp2p-swarm`: - `ExternalAddresses` - `ListenAddresses` A node's `PeerId` is always known to the caller, thus we can require them to pass it in. Related: libp2p#3124.
) This patch deprecates 3 out of 4 functions on `PollParameters`: - `local_peer_id` - `listened_addresses` - `external_addresses` The addresses can be obtained by inspecting the `FromSwarm` event. To make this easier, we introduce two utility structs in `libp2p-swarm`: - `ExternalAddresses` - `ListenAddresses` A node's `PeerId` is always known to the caller, thus we can require them to pass it in. Related: libp2p#3124.
Description
This patch deprecates 3 out of 4 functions on
PollParameters
:local_peer_id
listened_addresses
external_addresses
The addresses can be obtained by inspecting the
FromSwarm
event. To make this easier, we introduce two utility structs inlibp2p-swarm
:ExternalAddresses
ListenAddresses
A node's
PeerId
is always known to the caller, thus we can require them to pass it in.Related: #3124.
Notes
I am opening this PR to get an initial concept ACK.
It is still missing changelog entries and we might want to consider waiting for the introduction of
FromSwarm
to be merged before merging this. That would allow us to then extendFromSwarm::NewExternalAddress
with theAddressScore
that is tracked in theSwarm
which makesExternaAddresses
actually feature-equal with the currentPollParameters::external_addresses
.Links to any relevant issues
Open Questions
Change checklist
I have added tests that prove my fix is effective or that my feature works