pub struct DHTBuilder { /* private fields */ }
Expand description
Helps to configure and create new DHT instances.
Implementations§
Source§impl DHTBuilder
impl DHTBuilder
Sourcepub fn new() -> DHTBuilder
pub fn new() -> DHTBuilder
Creates a new DHTBuilder
Sourcepub fn initial_id(self, id: Id) -> Self
pub fn initial_id(self, id: Id) -> Self
Set the initial Id for your DHT node.
If you don’t specify one, DHT will try to generate one based on its external IPv4 address (if known). If it doesn’t know its external IPv4 address, DHT will generate a random Id and change it later if it learns that it’s not valid for its IPv4 address.
Sourcepub fn listen_addr(self, listen_addr: SocketAddrV4) -> Self
pub fn listen_addr(self, listen_addr: SocketAddrV4) -> Self
Sets the IPv4 address and port that the DHT should bind its UDP socket to.
If not specified, it will default to 0.0.0.0:6881
Sourcepub fn ip_source(self, ip_source: Box<dyn IPV4AddrSource + Send>) -> Self
pub fn ip_source(self, ip_source: Box<dyn IPV4AddrSource + Send>) -> Self
Provides an IPV4AddrSource implementation to the DHT.
DHT will use this object to learn its external IPv4 address and keep up to date when the IP changes. If unspecified, the default implementation is IPV4Consensus.
Sourcepub fn route_table(self, route_table: Box<dyn NodeStorage + Send>) -> Self
pub fn route_table(self, route_table: Box<dyn NodeStorage + Send>) -> Self
Provides a NodeStorage implementation to the DHT.
DHT will use this to store its routing tables. If unspecified, the default implementation is NodeBucketStorage which works roughly the BEP0005 describes.
Sourcepub fn settings(self, settings: DHTSettings) -> Self
pub fn settings(self, settings: DHTSettings) -> Self
Provides a DHTSettings object to the DHT.
DHTSettings can be built with DHTSettingsBuilder but the defaults should work fine in most cases.
Sourcepub fn build(self, shutdown_rx: ShutdownReceiver) -> Result<DHT, RustyDHTError>
pub fn build(self, shutdown_rx: ShutdownReceiver) -> Result<DHT, RustyDHTError>
Build a DHT
This must be called from within a tokio Runtime context because it constructs a tokio UdpSocket. See tokio::net::UdpSocket.
Trait Implementations§
Source§impl Clone for DHTBuilder
impl Clone for DHTBuilder
Source§fn clone(&self) -> DHTBuilder
fn clone(&self) -> DHTBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more