Tezos_gossipsub.Automatonmodule C : Gossipsub_intf.AUTOMATON_CONFIGmodule Peer = C.Subconfig.PeerModule for peer
module Topic = C.Subconfig.TopicModule for topic
module Message_id = C.Subconfig.Message_idModule for message_id
module Message = C.Subconfig.MessageModule for message
module Time : Tezos_base.TzPervasives.PRINTABLE with type t = C.Time.tModule for time
module Span : Gossipsub_intf.SPAN with type t = C.Time.spanModule for time duration
Module for peers scores
type message = Message.ttype span = Span.ttype limits := (Topic.t, Peer.t, Message_id.t, span) Gossipsub_intf.limitsLimits of the gossipsub protocol.
type parameters := (Peer.t, Message_id.t) Gossipsub_intf.parametersParameters of the gossipsub protocol.
The types of payloads for inputs to the gossipsub automaton.
type prune = {peer : Peer.t;topic : Topic.t;px : Peer.t Tezos_base.TzPervasives.Seq.t;backoff : span;}type receive_message = {sender : Peer.t;topic : Topic.t;message_id : Message_id.t;message : message;}type _ output = | Ihave_from_peer_with_low_score : {score : Score.t;threshold : float;} -> [ `IHave ] outputThe peer who sent an IHave message has a score below threshold.
| Too_many_recv_ihave_messages : {} -> [ `IHave ] outputThe peer sent us more than max IHave messages within two successive heartbeat calls.
| Too_many_sent_iwant_messages : {} -> [ `IHave ] outputWe sent more than max IWant messages to this peer within two successive heartbeat calls.
| Message_topic_not_tracked : [ `IHave ] outputWe received an IHave message for a topic we don't track.
*)| Message_requested_message_ids : Message_id.t list -> [ `IHave ] outputThe messages ids we want to request from the peer which sent us an IHave message. The implementation honors the max_sent_iwant_per_heartbeat limit.
| Invalid_message_id : [ `IHave ] outputA message id received via IHave message is invalid.
*)| Iwant_from_peer_with_low_score : {score : Score.t;threshold : float;} -> [ `IWant ] outputThe peer who sent an IWant message has a score below threshold.
| On_iwant_messages_to_route : {routed_message_ids : [ `Ignored
| `Not_found
| `Too_many_requests
| `Message of message ]
Message_id.Map.t;} -> [ `IWant ] outputAs an answer for an `IWant message, the automaton returns a map associating to each requested message_id either `Ignored if the peer is filtered out by peer_filter, `Not_found if the message is not found, or Message m if m is the message with the given id.
| Peer_filtered : [ `Graft ] outputThe peer we attempt to graft has not been selected by peer_filter.
| Unsubscribed_topic : [ `Graft ] outputWe didn't join the topic for which we are attempting to graft a peer.
*)| Peer_already_in_mesh : [ `Graft ] outputAttempting to graft a peer which has already been grafted.
*)| Grafting_direct_peer : [ `Graft ] outputAttempting to graft a direct peer.
*)| Unexpected_grafting_peer : [ `Graft ] outputThe peer we attempt to graft is not known.
*)| Grafting_peer_with_negative_score : [ `Graft ] outputAttempting to graft a peer with a negative score.
*)| Grafting_successfully : [ `Graft ] outputGrafting the given peer for the provided topic succeeded.
*)| Peer_backed_off : [ `Graft ] outputWe cannot graft the given peer because it is backed off.
*)| Mesh_full : [ `Graft ] outputGrafting a peer for a topic whose mesh has already sufficiently many peers.
*)| Prune_topic_not_tracked : [ `Prune ] outputAttempting to prune a peer for a non-tracked topic.
*)| Peer_not_in_mesh : [ `Prune ] outputAttempting to prune a peer which is not in the mesh.
*)| Ignore_PX_score_too_low : Score.t -> [ `Prune ] outputThe given peer has been pruned for the given topic, but no alternative peers are returned because the peer's score is too low. The score of the peer is included in the return value.
*)| No_PX : [ `Prune ] outputThe given peer has been pruned for the given topic. No alternatives peers was provided in prune.
| PX : Peer.Set.t -> [ `Prune ] outputThe given peer has been pruned for the given topic. The given set of peers alternatives in prune for that topic is returned.
| Publish_message : {to_publish : Peer.Set.t;} -> [ `Publish_message ] outputto_publish contains:
| Already_published : [ `Publish_message ] outputAttempting to publish a message that has already been published.
*)| Route_message : {to_route : Peer.Set.t;} -> [ `Receive_message ] outputto_route contains:
| Already_received : [ `Receive_message ] outputReceived a message that has already been received before.
*)| Not_subscribed : [ `Receive_message ] outputReceived a message from a remote peer for a topic we are not subscribed to (called "unknown topic" in the Go implementation).
*)| Invalid_message : [ `Receive_message ] outputAttempting to publish a message that is invalid.
*)| Unknown_validity : [ `Receive_message ] outputValidity cannot be decided yet.
*)| Outdated : [ `Receive_message ] outputThe message is outdated.
*)| To_include_in_batch : (receive_message * Peer.Set.t) -> [ `Receive_message ]
outputThe message passed all the Gossipsub checks. The worker should add this message in the current batch. It must be noted that most checks (especially cryptographic ones) are done when the batch is processed.
*)| Batch_result : (receive_message * [ `Receive_message ] output) list ->
[ `Treated_batch ]
outputResult of the processing of the batch. It contains the list of all messages of the batch with their respective output.
*)| Already_joined : [ `Join ] outputAttempting to join a topic we already joined.
*)| Joining_topic : {to_graft : Peer.Set.t;} -> [ `Join ] outputWhen successfully joining a topic, the set of grafted peers for that topic is returned.
*)| Not_joined : [ `Leave ] outputAttempting to leave a topic which we didn't join or had already left.
*)| Leaving_topic : {to_prune : Peer.Set.t;noPX_peers : Peer.Set.t;} -> [ `Leave ] outputWhen successfully leaving a topic, the set of pruned peers for that topic is returned alongside a subset of those peers for which no alternative PX will be proposed.
*)| Heartbeat : {to_graft : Topic.Set.t Peer.Map.t;The set of topics per peer that have been grafted.
*)to_prune : Topic.Set.t Peer.Map.t;The set of topics per peer that have been pruned.
*)noPX_peers : Peer.Set.t;Set of peers for which peer exchange (PX) will not be proposed.
*)} -> [ `Heartbeat ] output| Peer_added : [ `Add_peer ] outputThe output returned when successfully adding a peer.
*)| Peer_already_known : [ `Add_peer ] outputThe output returned when attempting to add a peer which is already known.
*)| Removing_peer : [ `Remove_peer ] outputThe output returned when successfully removing a peer.
*)| Subscribed : [ `Subscribe ] outputThe output returned once we successfully processed a subscribe request sent from a peer.
*)| Subscribe_to_unknown_peer : [ `Subscribe ] outputThe output returned when we receive a subscribe message from a peer we don't know.
*)| Unsubscribed : [ `Unsubscribe ] outputThe output returned once we successfully processed an unsubscribe request sent from a peer.
*)| Unsubscribe_from_unknown_peer : [ `Unsubscribe ] outputThe output returned when we receive an unsubscribe message from a peer we don't know.
*)| Set_application_score : [ `Set_application_score ] outputThe output returned when we set the application score of a peer
*)Output produced by one of the actions below.
val make : Stdlib.Random.State.t -> limits -> parameters -> stateInitialise a state.
add_peer { direct; outbound; peer } is called to notify a new connection. If direct is true, the gossipsub always forwards messages to those peers. outbound is true if it is an outbound connection, that is, a connection initiated by the local (not the remote) peer. Note however that the notion of "outbound" connections can be refined, relaxed or redefined by the application layer to fit its own needs.
val remove_peer : remove_peer -> [ `Remove_peer ] monadremove_peer { peer } notifies gossipsub that we are disconnected from a peer. Do note that the state still maintain information for this connection for retain_duration seconds.
handle_subscribe {topic; peer} handles a request from a remote peer informing us that it is subscribed to topic.
val handle_unsubscribe : unsubscribe -> [ `Unsubscribe ] monadhandle_unsubscribe {topic; peer} handles a request from a remote peer informing us that it unsubscribed from topic.
handle_ihave { peer; topic; message_ids } handles the gossip message IHave emitted by peer for topic with the message_ids.
handle_iwant { peer; message_ids } handles the gossip message IWant emitted by peer for topic with the message_ids.
handle_graft { peer; topic } handles the gossip message Graft emitted by peer for topic. This action allows to graft a connection to a full connection allowing the transmission of full messages for the given topic.
handle_prune { peer; topic; px; backoff } handles the gossip message Prune emitted by peer for topic. This action allows to prune a full connection. In that case, the remote peer can send a list of peers to connect to as well as a backoff time, which is a duration for which we cannot Graft this peer on this topic.
val handle_receive_message :
batching_configuration:message_handling ->
receive_message ->
[ `Receive_message ] monadhandle_receive_message ~batching_configuration received_message handles a received_message on the gossip network. The function returns either a rejection reason for the message or a set of peers to which:
batching_configuration is Sequential.val publish_message : publish_message -> [ `Publish_message ] monadpublish { topic; message_id; message } allows to publish a message on the gossip network from the local node. The function returns a set of peers to which the (full) message will be directly forwarded.
val heartbeat : [ `Heartbeat ] monadheartbeat executes the heartbeat routine of the algorithm.
join { topic } handles a join to a new topic. On success, the function returns the set of peers that have been grafted to form the mesh of the joined topic.
leave { topic } handles a leave from a topic. On success, the function returns the set of peers, forming the mesh, that have been pruned for that topic.
val apply_batch :
(receive_message * Peer.Set.t) list ->
[ `Treated_batch ] monadapply_batch batch handles a complete batch and outputs an element of the state monad which encapsulates the list of [`Receive_message] ouptut result for each entry of the batch.
val set_application_score :
set_application_score ->
[ `Set_application_score ] monadset_application_score {peer; score} handles setting the application score of peer. If the peer is not known, this does nothing.
val select_px_peers :
state ->
peer_to_prune:Peer.t ->
Topic.t ->
noPX_peers:Peer.Set.t ->
Peer.t listSelect random peers for Peer eXchange. Note that function is deterministic; however, it has side effects in that it updates the state's random state.
Select the gossip messages to be sent. These are IHave control messages referring to recently seen messages (that is, sent during the last history_gossip_length heartbeat ticks), to be sent to a random selection of peers. The message ids for a peer and a topic are also selected at random among the possible ones. At most max_sent_iwant_per_heartbeat message ids are sent.
The local peer will send gossip to at most gossip_factor * (total number of non-mesh/non-fanout peers), or degree_lazy random peers, whichever is greater.
Note that function is deterministic; however, it has side effects in that it updates the state's random state.
val pp_add_peer : Stdlib.Format.formatter -> add_peer -> unitval pp_remove_peer : Stdlib.Format.formatter -> remove_peer -> unitval pp_ihave : Stdlib.Format.formatter -> ihave -> unitval pp_iwant : Stdlib.Format.formatter -> iwant -> unitval pp_graft : Stdlib.Format.formatter -> graft -> unitval pp_prune : Stdlib.Format.formatter -> prune -> unitval pp_receive_message : Stdlib.Format.formatter -> receive_message -> unitval pp_publish_message : Stdlib.Format.formatter -> publish_message -> unitval pp_join : Stdlib.Format.formatter -> join -> unitval pp_leave : Stdlib.Format.formatter -> leave -> unitval pp_subscribe : Stdlib.Format.formatter -> subscribe -> unitval pp_unsubscribe : Stdlib.Format.formatter -> unsubscribe -> unitval pp_set_application_score :
Stdlib.Format.formatter ->
set_application_score ->
unitval pp_output : Stdlib.Format.formatter -> 'a output -> unitmodule Introspection : sig ... end