diff --git a/misc/server/CHANGELOG.md b/misc/server/CHANGELOG.md index 4f4e31bb7d8..62672ab0261 100644 --- a/misc/server/CHANGELOG.md +++ b/misc/server/CHANGELOG.md @@ -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) diff --git a/misc/server/src/behaviour.rs b/misc/server/src/behaviour.rs index 230d62a2ef3..b74aa3eb99c 100644 --- a/misc/server/src/behaviour.rs +++ b/misc/server/src/behaviour.rs @@ -1,4 +1,4 @@ -use std::{str::FromStr, time::Duration}; +use std::str::FromStr; use libp2p::{ autonat, identify, identity, kad, ping, relay, @@ -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()),