package tezos-p2p

  1. Overview
  2. Docs

P2P maintenance worker.

This worker enforces the connection bounds defined on the command-line or/and the configuration file.

The maintenance process is launched: . When any of the following future is resolved P2p_trigger.wait_too_few_connections P2p_trigger.wait_too_many_connections . When maintain is called . After maintenance_idle_time if none of the other conditions have been met.

If the number of connections is above the limit, the maintainer kills existing connections.

If below the limit, it tries to connect to points available from P2p_pool. If not enough connections can be obtained, it requests new points from P2p_pool using P2p_pool.broadcast msg, and wakes up the P2p_discovery worker. It then waits for new peers or points by waiting on futures P2p_trigger.wait_new_peer P2p_trigger.wait_new_point This is reiterated indefinitely every require_new_points_time.

type config = {
  1. maintenance_idle_time : Tezos_base.Time.System.Span.t;
    (*

    How long to wait at most before running a maintenance loop.

    *)
  2. 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 be revealed to the rest of the network.

    *)
  3. min_connections : int;
    (*

    Strict minimum number of connections

    *)
  4. max_connections : int;
    (*

    Maximum number of connections

    *)
  5. expected_connections : int;
    (*

    Targeted number of connections to reach

    *)
  6. time_between_looking_for_peers : Ptime.span;
    (*

    The maximum time between two bootstrap message broadcasts when there are not enough active connections and no new peer or point have been discovered.

    *)
}
type ('msg, 'meta, 'meta_conn) t

Type of a maintenance worker.

val create : ?discovery:P2p_discovery.t -> config -> ('msg, 'meta, 'meta_conn) P2p_pool.t -> ('msg, 'meta, 'meta_conn) P2p_connect_handler.t -> P2p_trigger.t -> log:(Tezos_base.P2p_connection.P2p_event.t -> unit) -> ('msg, 'meta, 'meta_conn) t

create ?discovery config pool triggers log returns a maintenance worker, with the discovery worker if present, for pool.

val activate : ('msg, 'meta, 'meta_conn) t -> unit

activate t starts the worker that will maintain connections

val maintain : ('msg, 'meta, 'meta_conn) t -> unit Lwt.t

maintain t gives a hint to maintenance worker t that maintenance is needed and returns whenever t has done a maintenance cycle.

val shutdown : ('msg, 'meta, 'meta_conn) t -> unit Lwt.t

shutdown t is a thread that returns whenever t has successfully shut down.