package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.tezos-gossipsub/Tezos_gossipsub/Worker/index.html
Module Tezos_gossipsub.Worker
Source
Parameters
module C : Gossipsub_intf.WORKER_CONFIGURATION
Signature
The state of a gossipsub worker.
We (re-)export the GS, Monad and Stream modules.
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;
outbound : 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.
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 {
}
(*Inform the p2p_output messages processor that we want to connect to the peer
*)px
advertised by some other peerorigin
.| Forget of {
}
(*Inform the p2p_output messages processor that we don't want to connect to the peer
*)px
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) ->
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 ->
t
make ~events_logging 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.
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.
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
.