Skip to content

P2PMessage

Purpose

An outgoing message to be delivered to another node over the network.

Type

Reception:

P2PMessageV1

Record with fields:

Source peer

Destination peer

Encapsulated message

  • sig: Signature

Signature over the above fields by src

Triggers:

TransportMessage

Behavior

The Transport engine looks up the transport addresses associated with the destination peer identity using a LookupIdentityRequest to the Network Identity Store engine. Address choice is influenced by the TransportPrefs specified in the encapsulated EngineMessage. If this lookup fails, the message is dropped.

Transport then wraps the P2PMessage in a TransportMessage with the selected TransportAddress. and sends it to the network using the corresponding transport protocol, establishing a new connection if not connected yet to the destination.

Once the connection is set up, Transport announces this via a NodeConnected notification. At the end of the connection, a NodeDisconnected notification is sent instead.

When a connection cannot be established immediately, the message is queued and sending periodically retried, possibly via different transport addresses, until the expiry time specified in the encapsulated EngineMessage is reached, after which the message is dropped.

Message flow

sequenceDiagram

%% --8<-- [start:sequence]
TransportProtocol -) Transport: TransportMessage
Transport -) Router: P2PMessage
Router -) Transport: P2PMessage
Transport -) TransportProtocol: TransportMessage
%% --8<-- [end:sequence]