pub struct ConfigBuilder { /* private fields */ }
Expand description
Configuration builder for Kademlia.
Implementations§
source§impl ConfigBuilder
impl ConfigBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create new ConfigBuilder
.
sourcepub fn with_replication_factor(self, replication_factor: usize) -> Self
pub fn with_replication_factor(self, replication_factor: usize) -> Self
Set replication factor.
sourcepub fn with_known_peers(self, peers: HashMap<PeerId, Vec<Multiaddr>>) -> Self
pub fn with_known_peers(self, peers: HashMap<PeerId, Vec<Multiaddr>>) -> Self
Seed Kademlia with one or more known peers.
sourcepub fn with_routing_table_update_mode(
self,
mode: RoutingTableUpdateMode,
) -> Self
pub fn with_routing_table_update_mode( self, mode: RoutingTableUpdateMode, ) -> Self
Set routing table update mode.
sourcepub fn with_incoming_records_validation_mode(
self,
mode: IncomingRecordValidationMode,
) -> Self
pub fn with_incoming_records_validation_mode( self, mode: IncomingRecordValidationMode, ) -> Self
Set incoming records validation mode.
sourcepub fn with_protocol_names(self, protocol_names: Vec<ProtocolName>) -> Self
pub fn with_protocol_names(self, protocol_names: Vec<ProtocolName>) -> Self
Set Kademlia protocol names, overriding the default protocol name.
The order of the protocol names signifies preference so if, for example, there are two protocols:
/kad/2.0.0
/kad/1.0.0
Where /kad/2.0.0
is the preferred version, then that should be in protocol_names
before
/kad/1.0.0
.
sourcepub fn with_record_ttl(self, record_ttl: Duration) -> Self
pub fn with_record_ttl(self, record_ttl: Duration) -> Self
Set default TTL for the records.
If unspecified, the default TTL is 36 hours.
sourcepub fn with_provider_record_ttl(self, provider_record_ttl: Duration) -> Self
pub fn with_provider_record_ttl(self, provider_record_ttl: Duration) -> Self
Set default TTL for the provider records. Recommended value is 2 * (refresh interval) + 20%.
If unspecified, the default TTL is 48 hours.
sourcepub fn build(self) -> (Config, KademliaHandle)
pub fn build(self) -> (Config, KademliaHandle)
Build Kademlia Config
.
Trait Implementations§
source§impl Debug for ConfigBuilder
impl Debug for ConfigBuilder
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more