bridge

Function bridge 

Source
pub fn bridge<S>(conn: ConnId, stream: S, port: Sender<Event>) -> Sender<Frame>
where S: AsyncRead + AsyncWrite + Send + Unpin + 'static,
Expand description

Run a connection as a peer of the node reached through port, answering with the way in to it. The outbound half comes back rather than registering itself, so whoever established the connection holds it before anything can name it: registering by event is a race the caller cannot wait out, since a task that already knows the far address could send first and be told there was no such link.

Every wait here is on the far side, never on the node. Room in the node’s queue is taken before there is anything to put in it - waiting for room while holding an unread outbound queue is a deadlock, not a slow path.