Events¶
Common Protocol Events¶
Common events used for all peer protocols. These events derive from BaseEvent
and
can thus be consumed through the event bus.
-
class
trinity.protocol.common.events.
ConnectToNodeCommand
(remote: p2p.abc.NodeAPI)¶ Event that wraps a node URI that the pool should connect to.
-
class
trinity.protocol.common.events.
PeerCountRequest
¶ Request event to get the count of peers connected to the pool.
-
static
expected_response_type
() → Type[trinity.protocol.common.events.PeerCountResponse]¶ Return the type that is expected to be send back for this request. This ensures that at runtime, only expected responses can be send back to callsites that issued a BaseRequestResponseEvent
-
static
-
class
trinity.protocol.common.events.
PeerCountResponse
(peer_count: int)¶ Response event that wraps the count of peers connected to the pool.
-
class
trinity.protocol.common.events.
DisconnectPeerEvent
(session: p2p.abc.SessionAPI, reason: p2p.disconnect.DisconnectReason)¶ Event broadcasted when we want to disconnect from a peer
-
class
trinity.protocol.common.events.
PeerJoinedEvent
(session: p2p.abc.SessionAPI)¶ Event broadcasted when a new peer joined the pool.
-
class
trinity.protocol.common.events.
PeerLeftEvent
(session: p2p.abc.SessionAPI)¶ Event broadcasted when a peer left the pool.
-
class
trinity.protocol.common.events.
GetConnectedPeersRequest
¶ A request class that can be dispatched from any process to be answered from another process with a
trinity.protocol.common.events.GetConnectedPeersResponse
.-
static
expected_response_type
() → Type[trinity.protocol.common.events.GetConnectedPeersResponse]¶ Return the type that is expected to be send back for this request. This ensures that at runtime, only expected responses can be send back to callsites that issued a BaseRequestResponseEvent
-
static
-
class
trinity.protocol.common.events.
GetConnectedPeersResponse
(peers: Tuple[trinity.protocol.common.events.PeerInfo, ...])¶ The response class to answer a
trinity.protocol.common.events.GetConnectedPeersRequest
-
class
trinity.protocol.common.events.
PeerPoolMessageEvent
(session: p2p.abc.SessionAPI, command: p2p.abc.CommandAPI[typing.Any][Any])¶ Base event for all peer messages that are routed through the event bus. The events are mapped to individual subclasses for every different
cmd
to allow efficient consumption through the event bus. The event type is used bidirectionally, for peer messages that originate in the peer pool and are propagated to any consuming party but also for peer messages that originate elsewhere but are propagated toward the peer pool to be dispatched on a peer.