Legend:
Library
Module
Module type
Parameter
Class
Class type
Tezos P2p layer - Dynamic overlay network of authenticated peers.
The P2P layer implements several mechanisms, notably:
It maintains pools of known points (P2P servers), peers (authenticated P2P servers), connections,
it implements an "administrative" protocol for maintaining the network topology,
it regulates bandwidth usage between connections,
it implements an authentication / session agreement protocol,
it can ban or greylist peers or IP addresses who don't behave well,
it offers the ability to the upper-layer to send, broadcast, or receive messages.
The protocol sends/receives messages to maintain the network topology, and also "generic" application messages that can be sent and received by the upper-layer. See P2p_message.
The protocol may operate in *private* mode, in which only user-provided points (a.k.a. *trusted* ) are used. In particular, points advertisements and swap requests messages are ignored.
The module P2p_pool maintains pools of points, peers and connections.
Several workers are used:
P2p_maintenance tries to regulate the number of connections
P2p_welcome waits for incoming connections
P2p_discovery looks for points on the local network via UDP messages
A protocol worker implements the messaging protocol
Points can be trusted. This is relevant in private mode (see above), but generally peers shouldn't advertise trusted points.
Addresses and peers can be *banned* (a.k.a. blacklisted). In which case, connections to and from them should be ignored.
Addresses or peers can be *greylisted*. As for banning, greylisting can be enforced via the API, but also dynamically when the peer isn't able to authenticate. Eventually greylisted peers are whitelisted again.
Many types used in the P2p layer are parameterized by three type parameters:
'msg: type of messages exchanged between peers
'peer_meta: type of the metadata associated with peers (score, etc.)
'conn_meta: type of the metadata associated with connections
The concrete types, and functions operating on them, are defined by the calling layer, and passed to P2p.create. See module P2p_params.
If incoming connections accepted, specifying the TCP port other peers should use to connect to this peer (default: listening_port). Can be used when this peer is behind NAT.
List of hard-coded known peers to bootstrap the network from.
*)
peers_file : string;
(*
The path to the JSON file where the metadata associated to peer_ids are loaded / stored.
*)
private_mode : bool;
(*
If true, only open outgoing/accept incoming connections to/from peers whose addresses are in trusted_peers, and inform these peers that the identity of this node should not be revealed to the rest of the network.
Returns the network version that will be used for this connection. This network version is the best version compatible with the versions supported by ours and the remote peer.
val disconnect :
('msg, 'peer_meta, 'conn_meta)net->?wait:bool ->('msg, 'peer_meta, 'conn_meta)connection->unit Lwt.t