diff --git a/src/node/net/p2p.ml b/src/node/net/p2p.ml index 053aea871..a41a5e43d 100644 --- a/src/node/net/p2p.ml +++ b/src/node/net/p2p.ml @@ -272,14 +272,15 @@ module Real = struct P2p_connection_pool.write_all pool msg ; Lwt.ignore_result (lwt_debug "message broadcasted") + let pool { pool } = pool end module Fake = struct let id = Identity.generate (Crypto_box.make_target 0.) let empty_stat = { - Stat.total_sent = 0 ; - total_recv = 0 ; + Stat.total_sent = 0L ; + total_recv = 0L ; current_inflow = 0 ; current_outflow = 0 ; } diff --git a/src/node/net/p2p_types.ml b/src/node/net/p2p_types.ml index c8c201d21..0f69270ea 100644 --- a/src/node/net/p2p_types.ml +++ b/src/node/net/p2p_types.ml @@ -45,12 +45,19 @@ end module Stat = struct type t = { - total_sent : int ; - total_recv : int ; + total_sent : int64 ; + total_recv : int64 ; current_inflow : int ; current_outflow : int ; } + let empty = { + total_sent = 0L ; + total_recv = 0L ; + current_inflow = 0 ; + current_outflow = 0 ; + } + let print_size ppf sz = let ratio n = (float_of_int sz /. float_of_int (1 lsl n)) in if sz < 1 lsl 10 then diff --git a/src/utils/moving_average.ml b/src/utils/moving_average.ml index eea6a4334..3ac4a82ea 100644 --- a/src/utils/moving_average.ml +++ b/src/utils/moving_average.ml @@ -18,7 +18,7 @@ module Inttbl = Hashtbl.Make(struct type t = { id: int; alpha: int ; - mutable total: int ; + mutable total: int64 ; mutable current: int ; mutable average: int ; } @@ -66,19 +66,19 @@ let create = incr cpt ; assert (0. < alpha && alpha <= 1.) ; let alpha = int_of_float (1000. *. alpha) in - let c = { id ; alpha ; total = 0 ; current = 0 ; average = init } in + let c = { id ; alpha ; total = 0L ; current = 0 ; average = init } in Inttbl.add counters id c ; c let add c x = - c.total <- c.total + x ; + c.total <- Int64.(add c.total (of_int x)) ; c.current <- c.current + x let destroy c = Inttbl.remove counters c.id type stat = { - total: int ; + total: int64 ; average: int ; } diff --git a/src/utils/moving_average.mli b/src/utils/moving_average.mli index 24acbe95b..131ecbf14 100644 --- a/src/utils/moving_average.mli +++ b/src/utils/moving_average.mli @@ -18,7 +18,7 @@ val on_update: (unit -> unit) -> unit val updated: unit Lwt_condition.t type stat = { - total: int ; + total: int64 ; average: int ; } val stat: t -> stat