pub async fn run_network_loop(
swarm: Swarm<BillPouchBehaviour>,
cmd_rx: Receiver<NetworkCommand>,
state: Arc<RwLock<NetworkState>>,
listen_addr: Multiaddr,
storage_managers: StorageManagerMap,
outgoing_assignments: OutgoingAssignments,
remote_fragment_index: Arc<RwLock<RemoteFragmentIndex>>,
) -> BpResult<()>Expand description
Drive the P2P event loop until shutdown.
Spawned as a background task by run_daemon. Runs a tokio::select!
loop that concurrently:
- polls the libp2p swarm for events (gossip, mDNS, Identify, Kademlia),
- reads
NetworkCommands fromcmd_rxand mutates swarm state.
The loop exits when the command channel is closed or a Shutdown command
is received.
§Arguments
swarm— the libp2p swarm built bybuild_swarm.cmd_rx— receiving end of the daemon → network command channel.state— sharedNetworkStateupdated from gossip messages.listen_addr— multiaddr to bind the TCP listener on.