package octez-libs
A package that contains multiple base libraries used by the Octez suite
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-libs.base/network_version.ml.html
Source file network_version.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
(*****************************************************************************) (* *) (* 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 t = { chain_name : Distributed_db_version.Name.t; distributed_db_version : Distributed_db_version.t; p2p_version : P2p_version.t; } let pp ppf {chain_name; distributed_db_version; p2p_version} = Format.fprintf ppf "%a.%a (p2p: %a)" Distributed_db_version.Name.pp chain_name Distributed_db_version.pp distributed_db_version P2p_version.pp p2p_version let encoding = let open Data_encoding in def "network_version" ~description: "A version number for the network protocol (includes distributed DB \ version and p2p version)" @@ conv (fun {chain_name; distributed_db_version; p2p_version} -> (chain_name, distributed_db_version, p2p_version)) (fun (chain_name, distributed_db_version, p2p_version) -> {chain_name; distributed_db_version; p2p_version}) (obj3 (req "chain_name" Distributed_db_version.Name.encoding) (req "distributed_db_version" Distributed_db_version.encoding) (req "p2p_version" P2p_version.encoding)) let greatest = function | [] -> raise (Invalid_argument "Network_version.greatest") | h :: t -> List.fold_left max h t let announced ~chain_name ~distributed_db_versions ~p2p_versions = assert (distributed_db_versions <> []) ; assert (p2p_versions <> []) ; { chain_name; distributed_db_version = greatest distributed_db_versions; p2p_version = greatest p2p_versions; } let may_select_version ~compare accepted_versions remote_version motive = let open Error_monad.Result_syntax in let best_local_version = greatest accepted_versions in if compare best_local_version remote_version <= 0 then return best_local_version else if List.mem ~equal:(fun a b -> compare a b = 0) remote_version accepted_versions then return remote_version else P2p_rejection.rejecting motive let select ~chain_name ~distributed_db_versions ~p2p_versions remote = let open Error_monad.Result_syntax in assert (distributed_db_versions <> []) ; assert (p2p_versions <> []) ; if chain_name <> remote.chain_name then P2p_rejection.rejecting Unknown_chain_name else let+ distributed_db_version = may_select_version ~compare:Distributed_db_version.compare distributed_db_versions remote.distributed_db_version Deprecated_distributed_db_version and+ p2p_version = may_select_version ~compare:P2p_version.compare p2p_versions remote.p2p_version Deprecated_p2p_version in {chain_name; distributed_db_version; p2p_version} let () = Data_encoding.Registration.register ~pp encoding module Internal_for_tests = struct let mock () = { chain_name = Distributed_db_version.Name.of_string ""; distributed_db_version = Distributed_db_version.zero; p2p_version = P2p_version.zero; } end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>