package tezos-dal-node-lib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/tezos-dal-node-lib.gossipsub/Tezos_dal_node_lib_gossipsub/Gossipsub/Worker/index.html
Module Gossipsub.Worker
Source
The worker module exposes instantiation of the Gossipsub worker functor, alongside the config used to instantiate the functor and the default values of the GS parameters.
module Config :
module type of Gs_interface.Worker_config
with type GS.Topic.t = Tezos_dal_node_services.Types.Topic.t
and type GS.Message_id.t = Tezos_dal_node_services.Types.Message_id.t
and type GS.Message.t = Tezos_dal_node_services.Types.Message.t
and type GS.Peer.t = Tezos_dal_node_services.Types.Peer.t
and type GS.Span.t = Tezos_dal_node_services.Types.Span.t
and type GS.Time.t = Tezos_dal_node_services.Types.Time.t
and type 'a Monad.t = 'a Lwt.t
and type Point.t = Tezos_dal_node_services.Types.Point.t
This module defines the default values for simple Gossip parameters and limits. These values are used or re-defined in the DAL node before instantiating the Gossipsub worker.
include Tezos_gossipsub.Gossipsub_intf.WORKER
with type GS.Topic.t = Tezos_dal_node_services.Types.Topic.t
and type GS.Message_id.t = Tezos_dal_node_services.Types.Message_id.t
and type GS.Message.t = Tezos_dal_node_services.Types.Message.t
and type GS.Peer.t = Tezos_dal_node_services.Types.Peer.t
and type GS.Span.t = Tezos_dal_node_services.Types.Span.t
and type GS.Time.t = Tezos_dal_node_services.Types.Time.t
and type Point.t = Tezos_dal_node_services.Types.Point.t
The state of a gossipsub worker.
We (re-)export the GS, Monad and Stream modules.
include Tezos_gossipsub.Gossipsub_intf.WORKER_CONFIGURATION
with type GS.Topic.t = Tezos_dal_node_services.Types.Topic.t
with type GS.Message_id.t = Tezos_dal_node_services.Types.Message_id.t
with type GS.Message.t = Tezos_dal_node_services.Types.Message.t
with type GS.Peer.t = Tezos_dal_node_services.Types.Peer.t
with type GS.Span.t = Tezos_dal_node_services.Types.Span.t
with type GS.Time.t = Tezos_dal_node_services.Types.Time.t
with type Point.t = Tezos_dal_node_services.Types.Point.t
module GS :
Tezos_gossipsub.Gossipsub_intf.AUTOMATON
with type Topic.t = Tezos_dal_node_services.Types.Topic.t
with type Message_id.t = Tezos_dal_node_services.Types.Message_id.t
with type Message.t = Tezos_dal_node_services.Types.Message.t
with type Peer.t = Tezos_dal_node_services.Types.Peer.t
with type Span.t = Tezos_dal_node_services.Types.Span.t
with type Time.t = Tezos_dal_node_services.Types.Time.t
The gossipsub automaton that will be used by the worker.
module Point :
Tezos_gossipsub.Gossipsub_intf.ITERABLE
with type t = Tezos_dal_node_services.Types.Point.t
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".
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
The 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.
type app_input =
| Publish_message of message_with_header
| Join of GS.Topic.t
| Leave of GS.Topic.t
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 peerto_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 peerorigin
.| 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 peerorigin
.
The different kinds of outputs that could be emitted by the worker for the P2P layer.
The application layer will be advertised about full messages it's interested in.
The different kinds of events the Gossipsub worker handles.
val make :
?events_logging:(event -> unit Monad.t) ->
?bootstrap_points:Point.t list ->
Random.State.t ->
(GS.Topic.t, GS.Peer.t, GS.Message_id.t, GS.span)
Tezos_gossipsub.Gossipsub_intf.limits ->
(GS.Peer.t, GS.Message_id.t) Tezos_gossipsub.Gossipsub_intf.parameters ->
t
make ~events_logging ~bootstrap_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. The list of bootstrap_points
represents the list of initially known peers' addresses to which we may want to reconnect in the worker.
start topics state
runs the (not already started) worker whose state
is given together with the initial list of topics
the caller is interested in.
shutdown state
allows stopping the worker whose state
is given.
app_input state app_input
adds the given application input app_input
to the worker's input stream.
p2p_input state p2p_input
adds the given P2P input p2p_input
to the worker's input stream.
p2p_output_stream t
returns the output stream containing data for the P2P layer.
app_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.
is_subscribed t topic
checks whether topic
is in the mesh of t
.
Pretty-printer for values of type p2p_output
.
Pretty-printer for values of type app_output
.
Introspection and stats facilities
A hook to set or update messages and messages IDs validation function. Should be called once at startup and every time the DAL parameters change.