Enum litep2p::protocol::TransportEvent
source · pub enum TransportEvent {
ConnectionEstablished {
peer: PeerId,
endpoint: Endpoint,
},
ConnectionClosed {
peer: PeerId,
},
DialFailure {
peer: PeerId,
address: Multiaddr,
},
SubstreamOpened {
peer: PeerId,
protocol: ProtocolName,
fallback: Option<ProtocolName>,
direction: Direction,
substream: Substream,
},
SubstreamOpenFailure {
substream: SubstreamId,
error: SubstreamError,
},
}
Expand description
Events emitted by one of the installed transports to protocol(s).
Variants§
ConnectionEstablished
Connection established to peer
.
ConnectionClosed
Connection closed to peer.
DialFailure
Failed to dial peer.
This is reported to that protocol which initiated the connection.
SubstreamOpened
Substream opened for peer
.
Fields
protocol: ProtocolName
Protocol name.
One protocol handler may handle multiple sub-protocols (such as /ipfs/identify/1.0.0
and /ipfs/identify/push/1.0.0
) or it may have aliases which should be handled by
the same protocol handler. When the substream is sent from transport to the protocol
handler, the protocol name that was used to negotiate the substream is also sent so
the protocol can handle the substream appropriately.
fallback: Option<ProtocolName>
Fallback protocol.
direction: Direction
Substream direction.
Informs the protocol whether the substream is inbound (opened by the remote node) or outbound (opened by the local node). This allows the protocol to distinguish between the two types of substreams and execute correct code for the substream.
Outbound substreams also contain the substream ID which allows the protocol to distinguish between different outbound substreams.
SubstreamOpenFailure
Failed to open substream.
Substream open failures are reported only for outbound substreams.
Fields
substream: SubstreamId
Substream ID.
error: SubstreamError
Error that occurred when the substream was being opened.