-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(kad): report changes to our mode as an event #4499
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
Conversation
This PR replaces the messed up previous PR #4341 |
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.
Thanks for the creating a new PR!
The kademlia tests are still failing (correctly) because we are now emitting an additional event. For example, you'd have to add your new event to the following list:
rust-libp2p/protocols/kad/tests/client_mode.rs
Lines 22 to 23 in 1fff308
[MyBehaviourEvent::Identify(_), MyBehaviourEvent::Identify(_), MyBehaviourEvent::Kad(KademliaEvent::RoutingUpdated { peer, .. })], | |
[MyBehaviourEvent::Identify(_), MyBehaviourEvent::Identify(_)], |
I am adding this to the next milestone because it is a breaking change. Conventionally, we also set these PRs to |
Signed-off-by: Dave Huseby <[email protected]>
Signed-off-by: Dave Huseby <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
Signed-off-by: Dave Huseby <[email protected]>
Signed-off-by: Dave Huseby <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
Signed-off-by: Dave Huseby <[email protected]>
55d9dec
to
9dee364
Compare
So I was looking at the behavior of this change and I was wondering about what we want as the correct behavior. In the case where the Is it correct to say we only emit the event whenever we are in Also, the current behavior means that there's often—but not always—an initial event emitted from the first time a we try to determine our mode from the external addresses. There is a corner case where I suppose this all is as it should be. If you set the mode manually and turn of |
no force pushes... closed in lieu of PR #4503 |
Yep, that is my thinking too! If you set the mode manually, you don't need an event to tell you because you already have a code path where you can add whatever logic you want to do as a result of the new mode. |
Description
Previously, the kademlia protocol would only log changes to the internal mode. With this patch, we now also emit an event which allows users to code against the internal state of the kademlia protocol.
Fixes #4310.
Notes & open questions
I added the code to emit the event in the reconfigure_mode function on the assumption that all mode changes result in that function being called.
Change checklist