2018-02-08 13:51:00 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open P2p_peer
|
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
type ('conn, 'conn_meta) t =
|
2018-02-08 13:51:00 +04:00
|
|
|
| Accepted of { current_point: P2p_connection.Id.t ;
|
|
|
|
cancel: Lwt_canceler.t }
|
|
|
|
(** We accepted a incoming connection, we greeted back and
|
|
|
|
we are waiting for an acknowledgement. *)
|
|
|
|
| Running of { data: 'conn ;
|
2018-05-15 15:16:08 +04:00
|
|
|
conn_metadata: 'conn_meta ;
|
2018-02-08 13:51:00 +04:00
|
|
|
current_point: P2p_connection.Id.t }
|
|
|
|
(** Successfully authentificated connection, normal business. *)
|
|
|
|
| Disconnected
|
|
|
|
(** No connection established currently. *)
|
2018-05-15 15:16:08 +04:00
|
|
|
type ('conn, 'conn_meta) state = ('conn, 'conn_meta) t
|
2018-02-08 13:51:00 +04:00
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val pp : Format.formatter -> ('conn, 'conn_meta) t -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
module Info : sig
|
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
type ('conn, 'peer_meta, 'conn_meta) t
|
|
|
|
type ('conn, 'peer_meta, 'conn_meta) peer_info = ('conn, 'peer_meta, 'conn_meta) t
|
2018-02-08 13:51:00 +04:00
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val compare : ('conn, 'peer_meta, 'conn_meta) t -> ('conn, 'peer_meta, 'conn_meta) t -> int
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val create :
|
|
|
|
?created:Time.t ->
|
|
|
|
?trusted:bool ->
|
2018-05-15 15:16:08 +04:00
|
|
|
peer_metadata:'peer_meta ->
|
|
|
|
Id.t -> ('conn, 'peer_meta, 'conn_meta) peer_info
|
2018-02-08 13:51:00 +04:00
|
|
|
(** [create ~trusted ~meta peer_id] is a freshly minted peer_id info for
|
|
|
|
[peer_id]. *)
|
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val peer_id : ('conn, 'peer_meta, 'conn_meta) peer_info -> Id.t
|
2018-02-08 13:51:00 +04:00
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val created : ('conn, 'peer_meta, 'conn_meta) peer_info -> Time.t
|
|
|
|
val peer_metadata : ('conn, 'peer_meta, 'conn_meta) peer_info -> 'peer_meta
|
|
|
|
val set_peer_metadata : ('conn, 'peer_meta, 'conn_meta) peer_info -> 'peer_meta -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val trusted : ('conn, 'peer_meta, 'conn_meta) peer_info -> bool
|
|
|
|
val set_trusted : ('conn, 'peer_meta, 'conn_meta) peer_info -> unit
|
|
|
|
val unset_trusted : ('conn, 'peer_meta, 'conn_meta) peer_info -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val last_failed_connection :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
val last_rejected_connection :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
val last_established_connection :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
val last_disconnection :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val last_seen :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
(** [last_seen gi] is the most recent of:
|
|
|
|
|
|
|
|
* last established connection
|
|
|
|
* last rejected connection
|
|
|
|
* last disconnection
|
|
|
|
*)
|
|
|
|
|
|
|
|
val last_miss :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> (P2p_connection.Id.t * Time.t) option
|
2018-02-08 13:51:00 +04:00
|
|
|
(** [last_miss gi] is the most recent of:
|
|
|
|
|
|
|
|
* last failed connection
|
|
|
|
* last rejected connection
|
|
|
|
* last disconnection
|
|
|
|
*)
|
|
|
|
|
|
|
|
val log_incoming_rejection :
|
|
|
|
?timestamp:Time.t ->
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info -> P2p_connection.Id.t -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
module File : sig
|
|
|
|
val load :
|
2018-05-15 15:16:08 +04:00
|
|
|
string -> 'peer_meta Data_encoding.t ->
|
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info list tzresult Lwt.t
|
2018-02-08 13:51:00 +04:00
|
|
|
val save :
|
2018-05-15 15:16:08 +04:00
|
|
|
string -> 'peer_meta Data_encoding.t ->
|
|
|
|
('conn, 'peer_meta, 'conn_meta) peer_info list -> unit tzresult Lwt.t
|
2018-02-08 13:51:00 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
val fold :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) t -> init:'a -> f:('a -> Pool_event.t -> 'a) -> 'a
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val watch :
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) t -> Pool_event.t Lwt_stream.t * Lwt_watcher.stopper
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val get : ('conn, 'peer_meta, 'conn_meta) Info.t -> ('conn, 'conn_meta) state
|
2018-02-08 13:51:00 +04:00
|
|
|
|
2018-05-15 15:16:08 +04:00
|
|
|
val is_disconnected : ('conn, 'peer_meta, 'conn_meta) Info.t -> bool
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val set_accepted :
|
|
|
|
?timestamp:Time.t ->
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) Info.t -> P2p_connection.Id.t -> Lwt_canceler.t -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val set_running :
|
|
|
|
?timestamp:Time.t ->
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) Info.t -> P2p_connection.Id.t -> 'conn -> 'conn_meta -> unit
|
2018-02-08 13:51:00 +04:00
|
|
|
|
|
|
|
val set_disconnected :
|
|
|
|
?timestamp:Time.t ->
|
|
|
|
?requested:bool ->
|
2018-05-15 15:16:08 +04:00
|
|
|
('conn, 'peer_meta, 'conn_meta) Info.t -> unit
|