From 357ed403c427e70dc1a307e70e7e0c2718a4cd78 Mon Sep 17 00:00:00 2001 From: maqi Date: Fri, 27 Oct 2023 07:19:56 +0800 Subject: [PATCH] chore: expose hashed_bytes of KBucketKey Pull-Request: #4698. --- protocols/kad/CHANGELOG.md | 2 ++ protocols/kad/src/kbucket/key.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 3cf725e61e3..d2b92195ab3 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -6,6 +6,8 @@ See [PR 4503](https://github.com/libp2p/rust-libp2p/pull/4503). - Make previously "deprecated" `record` module private. See [PR 4035](https://github.com/libp2p/rust-libp2p/pull/4035). +- Expose hashed bytes of KBucketKey. + See [PR 4698](https://github.com/libp2p/rust-libp2p/pull/4698). - Remove previously deprecated type-aliases. Users should follow the convention of importing the `libp2p::kad` module and referring to symbols as `kad::Behaviour` etc. See [PR 4733](https://github.com/libp2p/rust-libp2p/pull/4733). diff --git a/protocols/kad/src/kbucket/key.rs b/protocols/kad/src/kbucket/key.rs index 93bcce793f0..bc5d6a53750 100644 --- a/protocols/kad/src/kbucket/key.rs +++ b/protocols/kad/src/kbucket/key.rs @@ -77,6 +77,11 @@ impl Key { self.bytes.distance(other) } + /// Exposing the hashed bytes. + pub fn hashed_bytes(&self) -> &[u8] { + &self.bytes.0 + } + /// Returns the uniquely determined key with the given distance to `self`. /// /// This implements the following equivalence: