offline tool: add global-fees cmd

This commit is contained in:
swrup 2026-02-03 15:56:05 +01:00
parent 4754517d8f
commit 4913d8ca76
8 changed files with 163 additions and 6 deletions

View file

@ -23,6 +23,23 @@ let of_span_exn = function
(* -- *)
(* TODO
this doesn't handle "never" value, and truncate time *)
let of_string s =
match Float.of_string_opt s with
| None -> Error "Timestamp.of_string failure: not a float"
| Some v -> (
match Ptime.of_float_s v with
| None -> Error "Timestamp.of_string failure"
| Some v -> Ok (Some v))
let pp fmt t =
match t with
| None -> Fmt.pf fmt {|"never"|}
| Some v ->
let v = Ptime.to_float_s v in
Fmt.pf fmt {|%f|} v
(* microseconds since the UNIX Epoch, or "never" if None *)
let jsont =
let number_or_never_jsont =
@ -80,6 +97,23 @@ let compare a b =
module Span = struct
type t = span
(* TODO
this doesn't handle "never" value, and truncate time *)
let of_string s =
match Float.of_string_opt s with
| None -> Error "Timestamp.Span.of_string failure: not a float"
| Some v -> (
match Ptime.Span.of_float_s v with
| None -> Error "Timestamp.Span.of_string failure"
| Some v -> Ok (Some v))
let pp fmt t =
match t with
| None -> Fmt.pf fmt {|"forever"|}
| Some v ->
let v = Ptime.Span.to_float_s v in
Fmt.pf fmt {|%f|} v
let to_int64 ptime = ptime |> Ptime.Span.to_float_s |> Int64.of_float
let of_int64 i =