Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file transport_layer_interface.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.com> *)(* Copyright (c) 2023 Functori, <contact@functori.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)moduleTypes=Tezos_dal_node_services.Types(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5583
Version this type to ease future migrations. *)moduleP2p_message_V1=structtypepx_peer={point:P2p_point.Id.t;peer:P2p_peer.Id.t}typep2p_message=|Graftof{topic:Types.Topic.t}|Pruneof{topic:Types.Topic.t;px:px_peerSeq.t;backoff:Types.Span.t;}|IHaveof{topic:Types.Topic.t;message_ids:Types.Message_id.tlist}|IWantof{message_ids:Types.Message_id.tlist}|Subscribeof{topic:Types.Topic.t}|Unsubscribeof{topic:Types.Topic.t}|Message_with_headerof{message:Types.Message.t;topic:Types.Topic.t;message_id:Types.Message_id.t;}letpx_peer_encoding=letopenData_encodinginconv(fun{point;peer}->(point,peer))(fun(point,peer)->{point;peer})(obj2(req"point"P2p_point.Id.encoding)(req"peer"P2p_peer.Id.encoding))(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5564
DAL/GS: bound the lists/seqs in exchanged p2p messages. *)letp2p_message_app_encoding=letopenData_encodinginletcase?max_length~tag~titleencodingunwrapwrap=P2p_params.Encoding{tag;title;encoding;wrap;unwrap;max_length}in[case~tag:0x10~title:"Graft"(obj2(req"kind"(constant"graft"))(req"topic"Types.Topic.encoding))(functionGraft{topic}->Some((),topic)|_->None)(fun((),topic)->Graft{topic});case~tag:0x11~title:"Prune"(obj4(req"kind"(constant"prune"))(req"topic"Types.Topic.encoding)(req"px"(listpx_peer_encoding))(req"backoff"Types.Span.encoding))(function|Prune{topic;px;backoff}->Some((),topic,List.of_seqpx,backoff)|_->None)(fun((),topic,px,backoff)->Prune{topic;px=List.to_seqpx;backoff});case~tag:0x12~title:"IHave"(obj3(req"kind"(constant"ihave"))(req"topic"Types.Topic.encoding)(req"message_ids"(listTypes.Message_id.encoding)))(function|IHave{topic;message_ids}->Some((),topic,message_ids)|_->None)(fun((),topic,message_ids)->IHave{topic;message_ids});case~tag:0x13~title:"IWant"(obj2(req"kind"(constant"iwant"))(req"message_ids"(listTypes.Message_id.encoding)))(functionIWant{message_ids}->Some((),message_ids)|_->None)(fun((),message_ids)->IWant{message_ids});case~tag:0x14~title:"Subscribe"(obj2(req"kind"(constant"subscribe"))(req"topic"Types.Topic.encoding))(functionSubscribe{topic}->Some((),topic)|_->None)(fun((),topic)->Subscribe{topic});case~tag:0x15~title:"Unsubscribe"(obj2(req"kind"(constant"unsubscribe"))(req"topic"Types.Topic.encoding))(functionUnsubscribe{topic}->Some((),topic)|_->None)(fun((),topic)->Unsubscribe{topic});case~tag:0x16~title:"Message_with_header"(obj4(req"kind"(constant"message_with_header"))(req"message"Types.Message.encoding)(req"topic"Types.Topic.encoding)(req"message_id"Types.Message_id.encoding))(function|Message_with_header{message;topic;message_id}->Some((),message,topic,message_id)|_->None)(fun((),message,topic,message_id)->Message_with_header{message;topic;message_id});]letp2p_message_encoding=letopenData_encodinginList.map(fun(P2p_params.Encoding{tag;title;encoding;wrap;unwrap;max_length=_})->case(Tagtag)~titleencodingunwrapwrap)p2p_message_app_encoding|>unionletpp_listpp_elt=Format.pp_print_list~pp_sep:(funfmt()->Format.fprintffmt"; ")pp_eltletpp_p2p_messagefmt=function|Graft{topic}->Format.fprintffmt"Graft{topic=%a}"Types.Topic.pptopic|Prune{topic;px;backoff}->Format.fprintffmt"Prune{topic=%a, px=%a, backoff=%a}"Types.Topic.pptopic(pp_listTypes.Peer.pp)(List.of_seqpx|>List.map(funpx_peer->px_peer.peer))Types.Span.ppbackoff|IHave{topic;message_ids}->Format.fprintffmt"IHave{topic=%a, message_ids=%a}"Types.Topic.pptopic(pp_listTypes.Message_id.pp)message_ids|IWant{message_ids}->Format.fprintffmt"IWant{message_ids=%a}"(pp_listTypes.Message_id.pp)message_ids|Subscribe{topic}->Format.fprintffmt"Subscribe{topic=%a}"Types.Topic.pptopic|Unsubscribe{topic}->Format.fprintffmt"Unsubscribe{topic=%a}"Types.Topic.pptopic|Message_with_header{message=_;message_id;topic=_}->Format.fprintffmt"FullMessage{message_id=%a}"Types.Message_id.ppmessage_idletdistributed_db_version=Distributed_db_version.zero(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5638
Decide how to safely choose the node db version. *)letdistributed_db_versions=[distributed_db_version]letmessage_config~network_name:p2p_messageP2p_params.message_config=letchain_name=Distributed_db_version.Name.of_stringnetwork_namein{encoding=p2p_message_app_encoding;chain_name;distributed_db_versions}endletversion~network_name=Network_version.{chain_name=Distributed_db_version.Name.of_stringnetwork_name;distributed_db_version=P2p_message_V1.distributed_db_version;p2p_version=P2p_version.one;}(* Exposed interface *)includeP2p_message_V1