Skip to content

fix(server): properly disable kademlia record storage #5987

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions misc/server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Changed

- Replace the zero-second TTL hack with proper record filtering in Kademlia.
See [PR 5987](https://github.com/libp2p/rust-libp2p/pull/5987)
- Deprecated #[clap] attributes with #[arg] and #[command].
See [PR 5932](https://github.com/libp2p/rust-libp2p/pull/5932)

Expand Down
9 changes: 3 additions & 6 deletions misc/server/src/behaviour.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{str::FromStr, time::Duration};
use std::str::FromStr;

use libp2p::{
autonat, identify, identity, kad, ping, relay,
Expand Down Expand Up @@ -32,11 +32,8 @@ impl Behaviour {
) -> Self {
let kademlia = if enable_kademlia {
let mut kademlia_config = kad::Config::new(IPFS_PROTO_NAME);
// Instantly remove records and provider records.
//
// TODO: Replace hack with option to disable both.
kademlia_config.set_record_ttl(Some(Duration::from_secs(0)));
kademlia_config.set_provider_record_ttl(Some(Duration::from_secs(0)));
// Disable storing records and provider records
kademlia_config.set_record_filtering(kad::StoreInserts::FilterBoth);
let mut kademlia = kad::Behaviour::with_config(
pub_key.to_peer_id(),
kad::store::MemoryStore::new(pub_key.to_peer_id()),
Expand Down
Loading