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_max_records(self, max_records: usize) -> Self
pub fn with_max_records(self, max_records: usize) -> Self
Set maximum number of records in the memory store.
If unspecified, the default maximum number of records is 1024.
Sourcepub fn with_max_record_size(self, max_record_size_bytes: usize) -> Self
pub fn with_max_record_size(self, max_record_size_bytes: usize) -> Self
Set maximum record size in bytes.
If unspecified, the default maximum record size is 65 KiB.
Sourcepub fn with_max_provider_keys(self, max_provider_keys: usize) -> Self
pub fn with_max_provider_keys(self, max_provider_keys: usize) -> Self
Set maximum number of provider keys in the memory store.
If unspecified, the default maximum number of provider keys is 1024.
Sourcepub fn with_max_provider_addresses(self, max_provider_addresses: usize) -> Self
pub fn with_max_provider_addresses(self, max_provider_addresses: usize) -> Self
Set maximum number of provider addresses per provider in the memory store.
If unspecified, the default maximum number of provider addresses is 30.
Sourcepub fn with_max_providers_per_key(self, max_providers_per_key: usize) -> Self
pub fn with_max_providers_per_key(self, max_providers_per_key: usize) -> Self
Set maximum number of providers per key in the memory store.
If unspecified, the default maximum number of providers per key is 20.
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 TTL for the provider records. Recommended value is 2 * (refresh interval) + 10%.
If unspecified, the default TTL is 48 hours.
Sourcepub fn with_provider_refresh_interval(
self,
provider_refresh_interval: Duration,
) -> Self
pub fn with_provider_refresh_interval( self, provider_refresh_interval: Duration, ) -> Self
Set the refresh (republish) interval for provider records.
If unspecified, the default interval is 22 hours.
Sourcepub fn with_max_message_size(self, max_message_size: usize) -> Self
pub fn with_max_message_size(self, max_message_size: usize) -> Self
Set the maximum Kademlia message size.
Should fit MemoryStore max record size. If unspecified, the default maximum message size
is 70 KiB.
Sourcepub fn build(self) -> (Config, KademliaHandle)
pub fn build(self) -> (Config, KademliaHandle)
Build Kademlia Config.