feat(swarm): report outcome of handling SwarmEvent#3865
Conversation
|
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
mxinden
left a comment
There was a problem hiding this comment.
Looks good to me. Though I would prefer not using once_cell::Lazy here for the sake of simplicity.
| static MEMORY_ADDR: Lazy<Multiaddr> = | ||
| Lazy::new(|| Multiaddr::empty().with(Protocol::Memory(1000))); |
There was a problem hiding this comment.
What is the value of a static over a const here? Why does it warrant introducing once_cell as a dependency?
There was a problem hiding this comment.
Multiaddr::empty and Multiaddr::with are unfortunately not const.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It is on the pathway to being stabilized and part of std: rust-lang/rust#105587
| static MEMORY_ADDR: Lazy<Multiaddr> = | ||
| Lazy::new(|| Multiaddr::empty().with(Protocol::Memory(1000))); |
There was a problem hiding this comment.
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.
Description
Previously, a user wouldn't know whether passing a
SwarmEventtoListenAddressesorExternalAddresseschanged the state. We now return a boolean wheretrueindicates that we handled the event and changed state as a result.The API is inspired by
HashSet::insertand the like.Notes & open questions
Extracted out of #3651.
Change checklist