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

feat(swarm): report outcome of handling SwarmEvent #3865

Merged
merged 6 commits into from
May 5, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

Previously, a user wouldn't know whether passing a SwarmEvent to ListenAddresses or ExternalAddresses changed the state. We now return a boolean where true indicates that we handled the event and changed state as a result.

The API is inspired by HashSet::insert and the like.

Notes & open questions

Extracted out of #3651.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

swarm/CHANGELOG.md Outdated Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented May 4, 2023

This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏

mxinden
mxinden previously approved these changes May 4, 2023
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Looks good to me. Though I would prefer not using once_cell::Lazy here for the sake of simplicity.

Comment on lines +96 to +97
static MEMORY_ADDR: Lazy<Multiaddr> =
Lazy::new(|| Multiaddr::empty().with(Protocol::Memory(1000)));
Copy link
Member

Choose a reason for hiding this comment

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

What is the value of a static over a const here? Why does it warrant introducing once_cell as a dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Multiaddr::empty and Multiaddr::with are unfortunately not const.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, right. I missed that.

I am hesitant to introduce a dependency just for the sake of more succinct test code. That said, once_cell seems to be everywhere, thus not really an additional dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is on the pathway to being stabilized and part of std: rust-lang/rust#105587

Comment on lines +96 to +97
static MEMORY_ADDR: Lazy<Multiaddr> =
Lazy::new(|| Multiaddr::empty().with(Protocol::Memory(1000)));
Copy link
Member

Choose a reason for hiding this comment

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

Ah, right. I missed that.

I am hesitant to introduce a dependency just for the sake of more succinct test code. That said, once_cell seems to be everywhere, thus not really an additional dependency.

@mxinden mxinden added the send-it label May 5, 2023
@mergify mergify bot merged commit eecfe2f into master May 5, 2023
@mergify mergify bot deleted the feat/report-changes-listen-addr branch May 5, 2023 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants