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.
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.