package octez-shell-libs
Octez shell libraries
Install
Dune Dependency
Authors
Maintainers
Sources
octez-19.1.tar.gz
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
doc/src/octez-shell-libs.p2p/p2p_message.ml.html
Source file p2p_message.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
(*****************************************************************************) (* *) (* 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 'msg t = | Bootstrap | Advertise of P2p_point.Id.t list | Swap_request of P2p_point.Id.t * P2p_peer.Id.t | Swap_ack of P2p_point.Id.t * P2p_peer.Id.t | Message of 'msg | Disconnect let encoding msg_encoding = let open Data_encoding in check_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 (Tag 0x01) ~title:"Disconnect" (obj1 (req "kind" (constant "Disconnect"))) (function Disconnect -> Some () | _ -> None) (fun () -> Disconnect); (* MAX SIZE: 2(tag) *) case (Tag 0x02) ~title:"Bootstrap" (obj1 (req "kind" (constant "Bootstrap"))) (function Bootstrap -> 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 (Tag 0x03) ~title:"Advertise" (obj2 (req "id" (Variable.list ~max_length:100 P2p_point.Id.encoding)) (req "kind" (constant "Advertise"))) (function Advertise points -> Some (points, ()) | _ -> None) (fun (points, ()) -> Advertise points); (* MAX SIZE: 2(tag) + (8 * 4) + 7 + 1 + 5 (point) + 16 (peer) = 63 *) case (Tag 0x04) ~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 (Tag 0x05) ~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.map msg_encoding ~f:(function | P2p_params.Encoding {tag; title; encoding; wrap; unwrap; max_length = _ (* ?? *)} -> Data_encoding.case (Tag tag) ~title encoding (function Message msg -> unwrap msg | _ -> None) (fun msg -> Message (wrap msg))))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>