pub struct CoreBuilder { /* private fields */ }Expand description
Structure containing necessary data to build Core.
Implementations§
Source§impl CoreBuilder
 
impl CoreBuilder
Sourcepub fn with_config(config: BootstrapConfig) -> Self
 
pub fn with_config(config: BootstrapConfig) -> Self
Return a CoreBuilder struct configured with BootstrapConfig and default values.
Here, it is certain that BootstrapConfig contains valid data.
Sourcepub fn with_network_id(self, protocol: String) -> Self
 
pub fn with_network_id(self, protocol: String) -> Self
Explicitly configure the network (protocol) id.
Note that it must be of the format “/protocol-name/version” otherwise it will default to
“/swarmnl/1.0”. See: DEFAULT_NETWORK_ID.
Sourcepub fn listen_on(self, ip_address: IpAddr) -> Self
 
pub fn listen_on(self, ip_address: IpAddr) -> Self
Configure the IP address to listen on.
If none is specified, the default value is Ipv4Addr::new(0, 0, 0, 0). See:
DEFAULT_IP_ADDRESS.
Sourcepub fn with_idle_connection_timeout(self, keep_alive_duration: Seconds) -> Self
 
pub fn with_idle_connection_timeout(self, keep_alive_duration: Seconds) -> Self
Configure how long to keep a connection alive (in seconds) once it is idling.
Sourcepub fn with_stream_size(self, size: usize) -> Self
 
pub fn with_stream_size(self, size: usize) -> Self
Configure the size of the stream buffers to use to track application requests to the network
layer internally. This should be as large an possible to prevent dropping off requests to
the network layer. Defaults to usize::MAX.
Sourcepub fn with_ping(self, config: PingConfig) -> Self
 
pub fn with_ping(self, config: PingConfig) -> Self
Configure the Ping protocol for the network.
Sourcepub fn with_replication(self, repl_cfg: ReplNetworkConfig) -> Self
 
pub fn with_replication(self, repl_cfg: ReplNetworkConfig) -> Self
Configure the Replication protocol for the network.
Sourcepub fn with_sharding<T: ShardStorage + 'static>(
    self,
    network_id: String,
    local_shard_storage: Arc<Mutex<T>>,
) -> Self
 
pub fn with_sharding<T: ShardStorage + 'static>( self, network_id: String, local_shard_storage: Arc<Mutex<T>>, ) -> Self
Configure the Sharding protocol for the network.
Sourcepub fn with_rpc(
    self,
    config: RpcConfig,
    handler: fn(RpcData) -> RpcData,
) -> Self
 
pub fn with_rpc( self, config: RpcConfig, handler: fn(RpcData) -> RpcData, ) -> Self
Configure the RPC protocol for the network.
Sourcepub fn with_kademlia(self, config: Config) -> Self
 
pub fn with_kademlia(self, config: Config) -> Self
Configure the Kademlia protocol for the network.
Sourcepub fn with_gossipsub(
    self,
    config: GossipsubConfig,
    filter_fn: fn(PeerId, MessageId, Option<PeerId>, String, Vec<String>) -> bool,
) -> Self
 
pub fn with_gossipsub( self, config: GossipsubConfig, filter_fn: fn(PeerId, MessageId, Option<PeerId>, String, Vec<String>) -> bool, ) -> Self
Configure the Gossipsub protocol for the network.
§Panics
This function panics if Gossipsub cannot be configured properly.
Sourcepub fn with_transports(self, transport: TransportOpts) -> Self
 
pub fn with_transports(self, transport: TransportOpts) -> Self
Configure the transports to support.
Sourcepub fn network_id(&self) -> String
 
pub fn network_id(&self) -> String
Return the id of the network.
Sourcepub async fn build(self) -> SwarmNlResult<Core>
 
pub async fn build(self) -> SwarmNlResult<Core>
Build the Core data structure.
Handles the configuration of the libp2p Swarm structure and the selected transport protocols, behaviours and node identity for tokio and async-std runtimes. The Swarm is wrapped in the Core construct which serves as the interface to interact with the internal networking layer.
Auto Trait Implementations§
impl Freeze for CoreBuilder
impl !RefUnwindSafe for CoreBuilder
impl Send for CoreBuilder
impl Sync for CoreBuilder
impl Unpin for CoreBuilder
impl !UnwindSafe for CoreBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
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
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more