123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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. *)(* *)(*****************************************************************************)typet={total_sent:int64;total_recv:int64;current_inflow:int;current_outflow:int;}letempty={total_sent=0L;total_recv=0L;current_inflow=0;current_outflow=0}letprint_sizeppfsz=letration=float_of_intsz/.float_of_int(1lsln)inifsz<1lsl10thenFormat.fprintfppf"%d B"szelseifsz<1lsl20thenFormat.fprintfppf"%.2f kiB"(ratio10)elseFormat.fprintfppf"%.2f MiB"(ratio20)letprint_size64ppfsz=letopenInt64inletration=to_floatsz/.float_of_int(1lsln)inifsz<shift_left1L10thenFormat.fprintfppf"%Ld B"szelseifsz<shift_left1L20thenFormat.fprintfppf"%.2f kiB"(ratio10)elseifsz<shift_left1L30thenFormat.fprintfppf"%.2f MiB"(ratio20)elseifsz<shift_left1L40thenFormat.fprintfppf"%.2f GiB"(ratio30)elseFormat.fprintfppf"%.2f TiB"(ratio40)letppppfstat=Format.fprintfppf"↗ %a (%a/s) ↘ %a (%a/s)"print_size64stat.total_sentprint_sizestat.current_outflowprint_size64stat.total_recvprint_sizestat.current_inflowletencoding=letopenData_encodingindef"p2p_stat"~description:"Statistics about the p2p network."@@conv(fun{total_sent;total_recv;current_inflow;current_outflow}->(total_sent,total_recv,current_inflow,current_outflow))(fun(total_sent,total_recv,current_inflow,current_outflow)->{total_sent;total_recv;current_inflow;current_outflow})(obj4(req"total_sent"int64)(req"total_recv"int64)(req"current_inflow"int31)(req"current_outflow"int31))let()=Data_encoding.Registration.register~ppencoding