Juvix imports
module arch.node.engines.router_messages;
import arch.node.engines.net_registry_messages open;
import arch.node.types.transport open;
import arch.node.types.basics open;
import arch.node.types.identities open;
import arch.node.types.messages open;
Router Messages¶
Message interface¶
type RouterMsg M :=
| RouterNodeAdvert NodeAdvert
| RouterMsgSend (NodeOutMsg M)
| RouterMsgRecv NodeMsg
| RouterMsgConnectRequest ConnectRequest
| RouterMsgConnectReply ConnectReply
| RouterMsgSetPermanence ConnectionPermanence;
Message types¶
RouterMsgSend
¶
Send an EngineMsg
to the remote node with the given transport preferences and
expiry time for send retries.
Expected sender: any local engine.
NodeOutMsg
¶
Outgoing message to a remote node.
Expected sender: any local engine.
type NodeOutMsg M :=
mkNodeOutMsg@{
prefs : TransportPrefs;
expiry : Time;
msg : EngineMsg M;
};
RouterMsgRecv
¶
Receive a message from the remote node.
Expected sender: local Transport Connection engine.
NodeMsg
¶
A message sent between nodes.
Sender: local Transport Connection engine.
type NodeMsg :=
mkNodeMsg@{
seq : Nat;
msg : EncryptedMsg;
};
Arguments
seq
- Message sequence number of the sender.
msg
- Encrypted
SerializedMsg
message that contains anEngineMsg
.
ConnectRequest
¶
Request a connection to a remote node.
The responder may accept or deny the request. As part of the connection establishment, first a protocol version negotiation takes place. the highest common supported protocol version is chosen, or else the connection fails.
Nodes let each other know about their own latest NodeAdvert
version, and the
version they know of from the other party, and if necessary, send each other an
updated NodeAdvert
after the connection is established.
Expected sender: remote Router engine.
type ConnectRequest :=
mkConnectRequest@{
proto_ver_min : Nat;
proto_ver_max : Nat;
src_node_id : NodeID;
dst_node_id : NodeID;
src_node_advert_ver : Nat;
dst_node_advert_ver : Nat;
};
Arguments
proto_ver_min
- Min. supported protocol version range.
proto_ver_max
- Max. supported protocol version range.
src_node_id
- Source node ID.
dst_node_id
- Destination node ID.
src_node_advert_ver
- Latest
NodeAdvert
version of the source node. dst_node_advert_ver
- Latest known
NodeAdvert
version of the destination node.
ConnectReply
¶
Reply to a ConnectRequest
.
ConnectReplyOk
¶
Accept a connection from a node.
type ConnectReplyOk :=
mkConnectReplyOk@{
proto_ver : Nat;
node_advert_ver : Pair Nat Nat;
};
Arguments
proto_ver
- Protocol version to use.
node_advert_ver
- Latest local
NodeAdvert
version.
ConnectReplyError
¶
Refuse a connection from a node.
type ConnectReplyError :=
| ConnectReplyErrorOverCapacity
| ConnectReplyErrorIncompatible
| ConnectReplyErrorDenied;
ConnectReplyError constructors
NodeConnectReplyErrorOverCapacity
- Node over capacity. Temporary failure.
NodeConnectReplyErrorIncompatible
- Incompatible protocol versions.
NodeConnectReplyErrorDenied
- Connection denied by local policy.
ConnectReply
¶
ConnectReply : Type := Result ConnectReplyOk ConnectReplyError;
SetPermanence
¶
Set connection permanence of the destination node to either ephemeral or permanent.
Permanent connections are automatically reconnected on node start and when the connection is lost.
type ConnectionPermanence :=
| RouterMsgConnectionEphemeral
| RouterMsgConnectionPermanent;
RouterMsg
¶
All Router engine messages.
type RouterMsg M :=
| RouterNodeAdvert NodeAdvert
| RouterMsgSend (NodeOutMsg M)
| RouterMsgRecv NodeMsg
| RouterMsgConnectRequest ConnectRequest
| RouterMsgConnectReply ConnectReply
| RouterMsgSetPermanence ConnectionPermanence;