+ wip MasterSignatures
This commit is contained in:
parent
f3de6ea80d
commit
d760a54b61
7 changed files with 136 additions and 68 deletions
24
src/api.ml
24
src/api.ml
|
|
@ -29,23 +29,33 @@ module ErrorDetail = struct
|
|||
|> Jsont.Object.finish
|
||||
end
|
||||
|
||||
module HashCode = struct
|
||||
module HashCode : sig
|
||||
type t
|
||||
|
||||
val hash : string -> t
|
||||
val jsont : t Jsont.t
|
||||
end = struct
|
||||
type t = B32.t
|
||||
|
||||
let hash s =
|
||||
let open Digestif.SHA256 in
|
||||
s |> digest_string |> to_raw_string
|
||||
|
||||
let jsont = Jsont.of_of_string ~kind:"HashCode" B32.decode ~enc:B32.encode
|
||||
end
|
||||
|
||||
module Amount = struct
|
||||
include Amount
|
||||
|
||||
let jsont = Jsont.of_of_string ~kind:"Amount" of_string ~enc:to_string
|
||||
end
|
||||
|
||||
module Timestamp = struct
|
||||
type t =
|
||||
| Seconds of float
|
||||
| Never
|
||||
|
||||
(* TODO time
|
||||
- time.ml
|
||||
- check this
|
||||
- what value for never?
|
||||
- better way for conversion to bin_types? *)
|
||||
let to_int64 t = match t with Never -> 0_L | Seconds v -> Int64.of_float v
|
||||
let to_ptime t = Util.ptime_of_int64 @@ to_int64 t
|
||||
let of_ptime p = Seconds (Ptime.to_float_s p)
|
||||
|
||||
let number_or_never_jsont =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue