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

mdns: MdnsConfig derives Clone and Debug. #2007

Merged
merged 2 commits into from
Mar 23, 2021
Merged

Conversation

dvc94ch
Copy link
Contributor

@dvc94ch dvc94ch commented Mar 20, 2021

Towards #2006 unblocks a new ipfs-embed release.

@dvc94ch dvc94ch force-pushed the mdns-config branch 3 times, most recently from 801f6c1 to 1b4a18e Compare March 21, 2021 10:36
swarm/src/lib.rs Outdated
Comment on lines 417 to 415
self.behaviour.inject_new_external_addr(&a);
self.external_addrs.add(a, s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.behaviour.inject_new_external_addr(&a);
self.external_addrs.add(a, s)
let result = self.external_addrs.add(a, s);
if let AddAddressResult::Inserted = &result {
self.behaviour.inject_new_external_addr(&a);
}
result

swarm/src/lib.rs Outdated
Comment on lines 428 to 425
self.behaviour.inject_expired_external_addr(addr);
self.external_addrs.remove(addr)
Copy link
Contributor

@romanb romanb Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.behaviour.inject_expired_external_addr(addr);
self.external_addrs.remove(addr)
if self.external_addrs.remove(addr) {
self.behaviour.inject_expired_external_addr(addr);
}

However, note also that the most common way in which external addresses expire is as a result of new addresses being added. See https://github.com/libp2p/rust-libp2p/blob/master/swarm/src/registry.rs#L186-L196. So, to be able to properly invoke this callback whenever an external address expires, I think you would need to incorporate the expired/removed addresses within a call to add() in the AddAddressResult, so that the Swarm can then invoke the callback for each.

@romanb
Copy link
Contributor

romanb commented Mar 22, 2021

The additions generally look good to me. We just need to make sure that the new callbacks are called only (and always) when appropriate.

swarm/src/behaviour.rs Outdated Show resolved Hide resolved
@mxinden mxinden changed the title Derive Clone, Debug. swarm: Extend NetworkBehaviour callbacks. Mar 22, 2021
Comment on lines +52 to +53
/// Configuration for mDNS.
#[derive(Clone, Debug)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extract this change to a separate pull request? Making only a single cohesive change per pull request makes maintaining this project a lot easier, especially around version and changelog management.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you renamed the PR, I moved the api changes, as this one has the branch name mdns-config

@dvc94ch dvc94ch changed the title swarm: Extend NetworkBehaviour callbacks. mdns: MdnsConfig derives Clone and Debug. Mar 22, 2021
@romanb romanb merged commit 987c244 into libp2p:master Mar 23, 2021
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.

3 participants