Skip to content

Commit cefd22b

Browse files
feat(kad): add mode getter on Behaviour (#5573)
## Description Small PR adding a getter for the `mode` attribute of the `kad::Behaviour` in order to get the mode that the DHT is operating in, at the moment. In our project, we needed to expose an API endpoint which included the mode that the DHT was operating. Having a getter was necessary so we are upstreaming this change. ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR which don't need to go into the final commit message. --> ## Change checklist <!-- Please add a Changelog entry in the appropriate crates and bump the crate versions if needed. See <https://github.com/libp2p/rust-libp2p/blob/master/docs/release.md#development-between-releases>--> - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates
1 parent e63975d commit cefd22b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

protocols/kad/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- Expose a kad query facility allowing specify num_results dynamicly.
44
See [PR 5555](https://github.com/libp2p/rust-libp2p/pull/5555).
5+
- Add `mode` getter on `Behaviour`.
6+
See [PR 5573](https://github.com/libp2p/rust-libp2p/pull/5573).
7+
58

69
## 0.46.2
710

protocols/kad/src/behaviour.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,11 @@ where
11111111
}
11121112
}
11131113

1114+
/// Get the [`Mode`] in which the DHT is currently operating.
1115+
pub fn mode(&self) -> Mode {
1116+
self.mode
1117+
}
1118+
11141119
fn reconfigure_mode(&mut self) {
11151120
if self.connections.is_empty() {
11161121
return;

0 commit comments

Comments
 (0)