Tezos_gossipsub.Workermodule C : Gossipsub_intf.WORKER_CONFIGURATIONWe (re-)export the GS, Monad and Stream modules.
include Gossipsub_intf.WORKER_CONFIGURATION
with module GS = C.GS
with module GS.Topic = C.GS.Topic
with module GS.Peer = C.GS.Peer
with module Monad = C.Monad
with module Stream = C.Stream
with module Point = C.Pointmodule GS :
module type of struct include C.GS end
with module Topic = C.GS.Topic
with module Peer = C.GS.PeerThe gossipsub automaton that will be used by the worker.
module Point = C.Pointmodule Monad = C.MonadAbstraction of the IO monad used by the worker.
module Stream = C.StreamA mutable (FIFO) stream of data.
type message_with_header = {message : GS.Message.t;topic : GS.Topic.t;message_id : GS.Message_id.t;}A message together with a header, that is, a topic and an id. This corresponds to what the spec calls a "full message".
TODO: https://gitlab.com/tezos/tezos/-/issues/5415 The topic can be inferred from the message_id and can thus be omitted; this also applies for the IHave message.
type p2p_message = | Graft of {topic : GS.Topic.t;}| Prune of {topic : GS.Topic.t;px : GS.Peer.t Tezos_base.TzPervasives.Seq.t;backoff : GS.Span.t;}| IHave of {topic : GS.Topic.t;message_ids : GS.Message_id.t list;}| IWant of {message_ids : GS.Message_id.t list;}| Subscribe of {topic : GS.Topic.t;}| Unsubscribe of {topic : GS.Topic.t;}| Message_with_header of message_with_header| PingThe following type defines the different kinds of messages a peer could receive from or sent to the P2P layer.
type p2p_input = | In_message of {from_peer : GS.Peer.t;p2p_message : p2p_message;}| New_connection of {peer : GS.Peer.t;direct : bool;trusted : bool;bootstrap : bool;}| Disconnection of {peer : GS.Peer.t;}The different kinds of input events that could be received from the P2P layer.
The different kinds of input events that could be received from the application layer.
A peer's origin is either another peer (i.e. advertised via PX), or none if it is trusted.
type p2p_output = | Out_message of {to_peer : GS.Peer.t;p2p_message : p2p_message;}Emit the given p2p_message to the remote peer to_peer.
| Disconnect of {peer : GS.Peer.t;}End the connection with the peer peer.
| Kick of {peer : GS.Peer.t;}Kick the peer peer: the peer is disconnected and blacklisted.
| Connect of {peer : GS.Peer.t;origin : peer_origin;}Inform the p2p_output messages processor that we want to connect to the peer peer advertised by some other peer origin.
| Connect_point of {point : Point.t;}Version of connect where we provide a point directly.
*)| Forget of {}Inform the p2p_output messages processor that we don't want to connect to the peer peer advertised by some other peer origin.
The different kinds of outputs that could be emitted by the worker for the P2P layer.
type app_output = message_with_headerThe application layer will be advertised about full messages it's interested in.
type event = private | Heartbeat| P2P_input of p2p_input| App_input of app_input| Check_unknown_messages| Process_batch of (GS.receive_message * GS.Peer.Set.t) listThe different kinds of events the Gossipsub worker handles.
val make :
?events_logging:(event -> unit Monad.t) ->
?initial_points:(unit -> Point.t list) ->
?batching_interval:GS.span ->
self:GS.Peer.t ->
Stdlib.Random.State.t ->
(GS.Topic.t, GS.Peer.t, GS.Message_id.t, GS.span) Gossipsub_intf.limits ->
(GS.Peer.t, GS.Message_id.t) Gossipsub_intf.parameters ->
tmake ~events_logging ~initial_points rng limits parameters initializes a new Gossipsub automaton with the given arguments. Then, it initializes and returns a worker for it. The events_logging function can be used to define a handler for logging the worker's events. initial_points allows to resolve a list of known peers' addresses to which we may want to reconnect in the worker.
val start : GS.Topic.t list -> t -> unitstart topics state runs the (not already started) worker whose state is given together with the initial list of topics the caller is interested in.
app_input state app_input adds the given application input app_input to the worker's input stream.
set_unreachable_point state point declares this point as unreachable.
p2p_input state p2p_input adds the given P2P input p2p_input to the worker's input stream.
val p2p_output_stream : t -> p2p_output Stream.tp2p_output_stream t returns the output stream containing data for the P2P layer.
val app_output_stream : t -> app_output Stream.tapp_output_stream t returns the output stream containing data for the application layer.
input_events_stream t returns the input stream in which we push events to be processed by the worker.
reconnection_delays t returns the points that are currently unreachable with the span before the next attempt to reconnect to them.
val is_subscribed : t -> GS.Topic.t -> boolis_subscribed t topic checks whether topic is in the mesh of t.
val pp_p2p_output : Stdlib.Format.formatter -> p2p_output -> unitPretty-printer for values of type p2p_output.
val pp_app_output : Stdlib.Format.formatter -> app_output -> unitPretty-printer for values of type app_output.
module Introspection : sig ... endIntrospection and stats facilities
val stats : t -> Introspection.statsval state : t -> GS.Introspection.viewval worker_crashed : t -> unit Lwt.t