Struct locutus_core::NodeConfig
source · pub struct NodeConfig<const CLIENTS: usize> { /* private fields */ }
Expand description
When instancing a node you can either join an existing network or bootstrap a new network with a listener which will act as the initial provider. This initial peer will be listening at the provided port and assigned IP. If those are not free the instancing process will return an error.
In order to bootstrap a new network the following arguments are required to be provided to the builder:
- ip: IP associated to the initial node.
- port: listening port of the initial node.
If both are provided but also additional peers are added via the Self::add_gateway()
method, this node will
be listening but also try to connect to an existing peer.
Implementations§
source§impl<const CLIENTS: usize> NodeConfig<CLIENTS>
impl<const CLIENTS: usize> NodeConfig<CLIENTS>
pub fn new(clients: [BoxedClient; CLIENTS]) -> NodeConfig<CLIENTS>
pub fn max_hops_to_live(&mut self, num_hops: usize) -> &mut Self
pub fn rnd_if_htl_above(&mut self, num_hops: usize) -> &mut Self
pub fn max_number_of_connections(&mut self, num: usize) -> &mut Self
pub fn min_number_of_connections(&mut self, num: usize) -> &mut Self
pub fn with_port(&mut self, port: u16) -> &mut Self
pub fn with_ip<T: Into<IpAddr>>(&mut self, ip: T) -> &mut Self
sourcepub fn with_key(&mut self, key: Keypair) -> &mut Self
pub fn with_key(&mut self, key: Keypair) -> &mut Self
Optional identity key of this node. If not provided it will be either obtained from the configuration or freshly generated.
pub fn with_location(&mut self, loc: Location) -> &mut Self
sourcepub fn add_gateway(&mut self, peer: InitPeerNode) -> &mut Self
pub fn add_gateway(&mut self, peer: InitPeerNode) -> &mut Self
Connection info for an already existing peer. Required in case this is not a gateway node.