From c0655fed8915490f82d4acf8900a16a10554cbfb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 14 Feb 2024 05:47:11 +0100 Subject: [PATCH] docs: add a few more docs for network loop (#6595) Co-authored-by: Oliver Nordbjerg --- crates/net/network/src/swarm.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/net/network/src/swarm.rs b/crates/net/network/src/swarm.rs index ca97bb30ca..13d479e050 100644 --- a/crates/net/network/src/swarm.rs +++ b/crates/net/network/src/swarm.rs @@ -112,6 +112,9 @@ where } /// Handles a polled [`SessionEvent`] + /// + /// This either updates the state or produces a new [`SwarmEvent`] that is bubbled up to the + /// manager. fn on_session_event(&mut self, event: SessionEvent) -> Option { match event { SessionEvent::SessionEstablished { @@ -302,6 +305,9 @@ where fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let this = self.get_mut(); + // This loop advances the network's state prioritizing local work [NetworkState] over work + // coming in from the network [SessionManager], [ConnectionListener] + // Existing connections are prioritized over new __incoming__ connections loop { while let Poll::Ready(action) = this.state.poll(cx) { if let Some(event) = this.on_state_action(action) {