Struct network_builder::builder::NetworkBuilder
source · pub struct NetworkBuilder { /* private fields */ }
Expand description
Build Network module with custom configuration values.
Methods can be chained in order to set the configuration values.
MempoolNetworkHandler and ConsensusNetworkHandler are constructed by calling
NetworkBuilder::build
. New instances of NetworkBuilder
are obtained
via NetworkBuilder::create
.
Implementations§
source§impl NetworkBuilder
impl NetworkBuilder
sourcepub fn new(
chain_id: ChainId,
trusted_peers: Arc<RwLock<PeerSet>>,
network_context: Arc<NetworkContext>,
time_service: TimeService,
listen_address: NetworkAddress,
authentication_mode: AuthenticationMode,
max_frame_size: usize,
enable_proxy_protocol: bool,
network_channel_size: usize,
max_concurrent_network_reqs: usize,
inbound_connection_limit: usize,
inbound_rate_limit_config: Option<RateLimitConfig>,
outbound_rate_limit_config: Option<RateLimitConfig>
) -> Self
pub fn new( chain_id: ChainId, trusted_peers: Arc<RwLock<PeerSet>>, network_context: Arc<NetworkContext>, time_service: TimeService, listen_address: NetworkAddress, authentication_mode: AuthenticationMode, max_frame_size: usize, enable_proxy_protocol: bool, network_channel_size: usize, max_concurrent_network_reqs: usize, inbound_connection_limit: usize, inbound_rate_limit_config: Option<RateLimitConfig>, outbound_rate_limit_config: Option<RateLimitConfig> ) -> Self
Return a new NetworkBuilder initialized with default configuration values.
pub fn new_for_test( chain_id: ChainId, seeds: PeerSet, trusted_peers: Arc<RwLock<PeerSet>>, network_context: Arc<NetworkContext>, time_service: TimeService, listen_address: NetworkAddress, authentication_mode: AuthenticationMode ) -> NetworkBuilder
sourcepub fn create(
chain_id: ChainId,
role: RoleType,
config: &NetworkConfig,
time_service: TimeService
) -> NetworkBuilder
pub fn create( chain_id: ChainId, role: RoleType, config: &NetworkConfig, time_service: TimeService ) -> NetworkBuilder
Create a new NetworkBuilder based on the provided configuration.
sourcepub fn build(&mut self, executor: Handle) -> &mut Self
pub fn build(&mut self, executor: Handle) -> &mut Self
Create the configured Networking components.
pub fn reconfig_subscriptions(&mut self) -> &mut Vec<ReconfigSubscription> ⓘ
pub fn network_context(&self) -> Arc<NetworkContext>
pub fn conn_mgr_reqs_tx(&self) -> Option<Sender<ConnectivityRequest>>
pub fn listen_address(&self) -> NetworkAddress
sourcepub fn add_connectivity_manager(
&mut self,
seeds: PeerSet,
trusted_peers: Arc<RwLock<PeerSet>>,
max_outbound_connections: usize,
connection_backoff_base: u64,
max_connection_delay_ms: u64,
connectivity_check_interval_ms: u64,
channel_size: usize,
mutual_authentication: bool
) -> &mut Self
pub fn add_connectivity_manager( &mut self, seeds: PeerSet, trusted_peers: Arc<RwLock<PeerSet>>, max_outbound_connections: usize, connection_backoff_base: u64, max_connection_delay_ms: u64, connectivity_check_interval_ms: u64, channel_size: usize, mutual_authentication: bool ) -> &mut Self
Add a [ConnectivityManager
] to the network.
[ConnectivityManager
] is responsible for ensuring that we are connected
to a node iff. it is an eligible node and maintaining persistent
connections with all eligible nodes. A list of eligible nodes is received
at initialization, and updates are received on changes to system membership.
Note: a connectivity manager should only be added if the network is permissioned.
sourcepub fn add_protocol_handler<SenderT, EventT>(
&mut self,
(rpc_protocols, direct_send_protocols, queue_preference, max_queue_size_per_peer, counter): (Vec<ProtocolId>, Vec<ProtocolId>, QueueStyle, usize, Option<&'static IntCounterVec>)
) -> (SenderT, EventT)where
EventT: NewNetworkEvents,
SenderT: NewNetworkSender,
pub fn add_protocol_handler<SenderT, EventT>( &mut self, (rpc_protocols, direct_send_protocols, queue_preference, max_queue_size_per_peer, counter): (Vec<ProtocolId>, Vec<ProtocolId>, QueueStyle, usize, Option<&'static IntCounterVec>) ) -> (SenderT, EventT)where EventT: NewNetworkEvents, SenderT: NewNetworkSender,
Adds a endpoints for the provided configuration. Returns NetworkSender and NetworkEvent which can be attached to other components.