Skip to main content

legacy_peer_status

Function legacy_peer_status 

Source
fn legacy_peer_status(
    p2p_receiver: &Receiver<P2PConnectionState>,
    ci_receiver: &Receiver<Option<u64>>,
    session_count: u64,
) -> LegacyPeerStatus
Expand description

Status of a single peer, read from the p2p and consensus-item watch channels it is tracked by.

Each channel is read exactly once, into a local. watch::Receiver::borrow returns a guard over a parking_lot::RwLock, and Rust drops temporaries at the end of the enclosing statement rather than the sub-expression, so borrowing inline in a struct literal would keep several guards alive at once. That deadlocks the whole process: parking_lot’s RwLock is write-preferring, so a second borrow() of a channel this thread already holds a guard on blocks behind any writer that queued in between, and that writer can never drain because the first guard is still held. These are blocking waits, so every stuck request burns a tokio worker until the runtime has none left to poll the reactor with.