Module pea2pea::protocols

source ·
Expand description

Opt-in protocols available to the node; each protocol is expected to spawn its own task that runs throughout the node’s lifetime and handles a specific functionality. The communication with these tasks is done via dedicated handler objects.

A flowchart detailing how the protocols interact with a connection during its lifetime can be seen here.

Traits

  • Can be used to specify and enable network handshakes. Upon establishing a connection, both sides will need to adhere to the specified handshake rules in order to finalize the connection and be able to send or receive any messages.
  • Can be used to automatically perform some initial actions when a connection with a peer is fully established. The reason for its existence (instead of including such behavior in the Handshake impl) is that it allows the user to utilize Writing (if implemented and enabled) and OnDisconnect, while Handshake is very low-level and doesn’t provide any additional functionality - its purpose is only to establish a connection.
  • Can be used to automatically perform some extra actions when the connection with a peer is severed, which is especially practical if the disconnect is triggered automatically, e.g. due to the peer sending a noncompliant message or when the peer is the one to shut down the connection with the node.
  • Can be used to specify and enable reading, i.e. receiving inbound messages. If the Handshake protocol is enabled too, it goes into force only after the handshake has been concluded.
  • Can be used to specify and enable writing, i.e. sending outbound messages. If the Handshake protocol is enabled too, it goes into force only after the handshake has been concluded.