123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019 Nomadic Labs, <contact@nomadic-labs.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. *)(* *)(*****************************************************************************)type'msgt=|Bootstrap|AdvertiseofP2p_point.Id.tlist|Swap_requestofP2p_point.Id.t*P2p_peer.Id.t|Swap_ackofP2p_point.Id.t*P2p_peer.Id.t|Messageof'msg|Disconnectletencodingmsg_encoding=letopenData_encodingincheck_size(100*1024*1024)(*Very high, arbitrary upper bound for message encodings *)@@dynamic_size(* MAX SIZE:
4(size of size info)
+ MAX SIZE of encoding *)@@union(* MAX SIZE: max MAX SIZE of cases *)~tag_size:`Uint16([(* MAX SIZE: 2(tag)
Note that tags can be 1 or 2 bytes depending on the size of the
union. This union is of unknown size because it depends on
[msg_encoding]. As a result, we assume a maximum tag size of 2
bytes. *)case(Tag0x01)~title:"Disconnect"(obj1(req"kind"(constant"Disconnect")))(functionDisconnect->Some()|_->None)(fun()->Disconnect);(* MAX SIZE: 2(tag) *)case(Tag0x02)~title:"Bootstrap"(obj1(req"kind"(constant"Bootstrap")))(functionBootstrap->Some()|_->None)(fun()->Bootstrap);(* MAX SIZE:
2(tag)
+ (100(list length)
* ((8(number of IPv6 chunks) * 4(size of IPv6 chunks))
+ 7(IPv6 chunk separators)
+ 1(port separator)
+ 5(size of port number))
= 4502
*)case(Tag0x03)~title:"Advertise"(obj2(req"id"(Variable.list~max_length:100P2p_point.Id.encoding))(req"kind"(constant"Advertise")))(functionAdvertisepoints->Some(points,())|_->None)(fun(points,())->Advertisepoints);(* MAX SIZE:
2(tag)
+ (8 * 4) + 7 + 1 + 5 (point)
+ 16 (peer)
= 63
*)case(Tag0x04)~title:"Swap_request"(obj3(req"point"P2p_point.Id.encoding)(req"peer_id"P2p_peer.Id.encoding)(req"kind"(constant"Swap_request")))(function|Swap_request(point,peer_id)->Some(point,peer_id,())|_->None)(fun(point,peer_id,())->Swap_request(point,peer_id));(* MAX SIZE:
2(tag)
+ (8 * 4) + 7 + 1 + 5 (point)
+ 16 (peer)
= 63
*)case(Tag0x05)~title:"Swap_ack"(obj3(req"point"P2p_point.Id.encoding)(req"peer_id"P2p_peer.Id.encoding)(req"kind"(constant"Swap_ack")))(function|Swap_ack(point,peer_id)->Some(point,peer_id,())|_->None)(fun(point,peer_id,())->Swap_ack(point,peer_id));]@ListLabels.mapmsg_encoding~f:(function|P2p_params.Encoding{tag;title;encoding;wrap;unwrap;max_length=_(* ?? *)}->Data_encoding.case(Tagtag)~titleencoding(functionMessagemsg->unwrapmsg|_->None)(funmsg->Message(wrapmsg))))