package octez-shell-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
doc/octez-shell-libs.p2p/Tezos_p2p/P2p_message/index.html
Module Tezos_p2p.P2p_message
Source
This module defines the messages of the P2p layers.
P2p messages are parameterized by a generic upper-layer message type 'msg
. The P2p layer serializes these 'msg
using a 'msg encoding'
provided by the client of this lib.
The P2p protocol is simple and can be deduced mostly from the message type. To make the network topology more dynamic, it implements a simple peer swapping mechanism which works as follows.
Peer A sends a message : Swap_request (point, peer)
to B. If B is already connected to the peer, the message is ignored. Otherwise B picks a peer peer'
at point point'
and connect to peer
. If successful, it sends a response Swap_ack (point', peer')
to A. Upon reception of Swap_ack
. B tries to connected to peer'
. If successful, it disconnect from peer
.
type 'msg t =
| Bootstrap
(*Welcome message sent by a peer upon connection
*)| Advertise of Tezos_base.TzPervasives.P2p_point.Id.t list
(*Response to a
*)Bootstrap
message, contains list of known points| Swap_request of Tezos_base.TzPervasives.P2p_point.Id.t * Tezos_base.TzPervasives.P2p_peer.Id.t
(*Propose new peer/point and ask a peer/point to swap with
*)| Swap_ack of Tezos_base.TzPervasives.P2p_point.Id.t * Tezos_base.TzPervasives.P2p_peer.Id.t
(*Response to a swap request and propose peer/point to swap with.
*)| Message of 'msg
(*Generic upper-layer message
*)| Disconnect
(*Ending of connection, unused for now
*)
val encoding :
'a Tezos_base.TzPervasives.P2p_params.app_message_encoding list ->
'a t Tezos_base.TzPervasives.Data_encoding.t