Skip to main content

initialize_network

Function initialize_network 

Source
pub async fn initialize_network<Z, T, PR, CS>(
    protocol_request_handler_maker: PR,
    core_sync_svc: CS,
    config: P2PConfig<Z>,
    transport_config: TransportConfig<Z, T>,
    peer_sync_callback: Option<PeerSyncCallback>,
) -> Result<NetworkInterface<Z>, BoxError>
where Z: NetworkZone, T: Transport<Z>, Z::Addr: BorshDeserialize + BorshSerialize, PR: ProtocolRequestHandlerMaker<Z> + Clone, CS: CoreSyncSvc + Clone,
Expand description

Initializes the P2P NetworkInterface for a specific [NetworkZone].

This function starts all the tasks to maintain/accept/make connections.

If P2PConfig::offline no connections will be made or accepted.

ยงUsage

You must provide:

  • A protocol request handler, which is given to each connection
  • A core sync service, which keeps track of the sync state of our node