tezos-p2p

Tezos: library for a pool of P2P connections
type ('msg, 'peer, 'conn) t
type config = {
incoming_app_message_queue_size : int option;(*

Size of the message queue for user messages (messages returned by this module's read function.

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

*)
min_connections : int;(*

Strict minimum number of connections (triggers LogEvent.too_few_connections).

*)
max_connections : int;(*

Max number of connections. If it's reached, connect and accept will fail, i.e. not add more connections (also triggers LogEvent.too_many_connections).

*)
max_incoming_connections : int;(*

Max not-yet-authentified incoming connections. Above this number, accept will start dropping incoming connections.

*)
incoming_message_queue_size : int option;(*

Size of the incoming message queue internal of a peer's Reader (See P2p_connection.accept).

*)
outgoing_message_queue_size : int option;(*

Size of the outgoing message queue internal to a peer's Writer (See P2p_connection.accept).

*)
binary_chunks_size : int option;(*

Size (in bytes) of binary blocks that are sent to other peers. Default value is 64 kB.

*)
identity : Tezos_base.TzPervasives.P2p_identity.t;(*

Our identity.

*)
connection_timeout : Tezos_base.TzPervasives.Time.System.Span.t;(*

Maximum time allowed to the establishment of a connection.

*)
authentication_timeout : Tezos_base.TzPervasives.Time.System.Span.t;(*

Maximum time allowed to the establishment of a connection.

*)
reconnection_config : P2p_point_state.Info.reconnection_config;(*

Delay granted to a peer to perform authentication.

*)
proof_of_work_target : Tezos_crypto.Crypto_box.pow_target;(*

The proof of work target we require from peers.

*)
listening_port : Tezos_base.TzPervasives.P2p_addr.port option;(*

The TCP port on which the peer can be reached.

*)
advertised_port : Tezos_base.TzPervasives.P2p_addr.port option;(*

The TCP port advertised to other peers, the default is listening_port.

*)
}
val create : ?p2p_versions:Tezos_base.TzPervasives.P2p_version.t list -> config -> ( 'msg, 'peer, 'conn ) P2p_pool.t -> 'msg P2p_params.message_config -> 'conn P2p_params.conn_meta_config -> P2p_io_scheduler.t -> P2p_trigger.t -> log:( Tezos_base.TzPervasives.P2p_connection.P2p_event.t -> unit ) -> answerer:'msg P2p_answerer.t Lazy.t -> ( 'msg, 'peer, 'conn ) t

create ?p2p_version config pool message_config socket_meta_config scheduler triggers log answerer returns a connection handler.

config is a record of configuration parameters. triggers is a record of condition variable used to signal some events to other modules. log is a callback to signal events to the upper layer. answerer is a parameterized callback that defines how the p2p layer will reply to incoming P2p_message.t.

val config : ( _, _, _ ) t -> config

config t is the config argument passed to t at creation.

connect ?timeout t point tries to add a connection to point in t in less than timeout.

val accept : ( 'msg, 'peer, 'conn ) t -> P2p_fd.t -> Tezos_base.TzPervasives.P2p_point.Id.t -> unit

accept t fd point instructs t to start the process of accepting a connection from fd. point is the id of the connecting host.

Incoming connection from banned points, or when maximum number of connection is exceeded are refused. The maximum number of connections maybe be randomly increased by one. Socket fd is closed when the connection is refused.

val stat : ( 'msg, 'peer, 'conn ) t -> Tezos_base.TzPervasives.P2p_stat.t

stat t is a snapshot of current bandwidth usage for the entire connected peers.

val on_new_connection : ( 'msg, 'peer, 'conn ) t -> ( Tezos_base.TzPervasives.P2p_peer.Id.t -> ( 'msg, 'peer, 'conn ) P2p_conn.t -> unit ) -> unit

on_new_connection t f installs f as a hook for new connections in t.

val destroy : ( 'msg, 'peer, 'conn ) t -> unit Lwt.t