fix timestamp compare
This commit is contained in:
parent
26f01efec0
commit
9c87aa63ea
6 changed files with 15 additions and 22 deletions
|
|
@ -83,7 +83,7 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date =
|
|||
| None -> denom_l
|
||||
| Some timestamp ->
|
||||
List.filter
|
||||
(fun v -> Timestamp.geq v.Denomination.stamp_start timestamp)
|
||||
(fun v -> Timestamp.compare timestamp v.Denomination.stamp_start <= 0)
|
||||
denom_l
|
||||
in
|
||||
let* denominations = Denomination.make_denom_group_sorted denom_l in
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ module Auditors = struct
|
|||
Logs.info (fun m -> m "enabled auditor");
|
||||
()
|
||||
| Some auditor ->
|
||||
if Timestamp.geq auditor.last_change validity_start then
|
||||
if Timestamp.compare validity_start auditor.last_change <= 0 then
|
||||
Error "replay detected on enable-auditor"
|
||||
else
|
||||
let+ () = Pg.update_auditor db_conn auditor |> unwrap_err_caqti in
|
||||
|
|
@ -157,7 +157,7 @@ module Auditors_disable = struct
|
|||
match opt with
|
||||
| None -> Error "auditor not found"
|
||||
| Some auditor -> (
|
||||
if Timestamp.geq auditor.last_change validity_end then
|
||||
if Timestamp.compare validity_end auditor.last_change <= 0 then
|
||||
Error "replay detected on disable-auditor"
|
||||
else
|
||||
match auditor.is_active with
|
||||
|
|
@ -384,7 +384,7 @@ module Wire = struct
|
|||
Logs.info (fun m -> m "added wire method");
|
||||
()
|
||||
| Some (wire, _is_active, last_change) ->
|
||||
if Timestamp.geq last_change validity_start then
|
||||
if Timestamp.compare validity_start last_change <= 0 then
|
||||
Error "replay detected on enable-wire"
|
||||
else
|
||||
let+ () =
|
||||
|
|
@ -423,7 +423,7 @@ module Wire_disable = struct
|
|||
match opt with
|
||||
| None -> Error "wire not found"
|
||||
| Some (wire, _is_active, last_change) ->
|
||||
if Timestamp.geq last_change validity_end then
|
||||
if Timestamp.compare validity_end last_change <= 0 then
|
||||
Error "replay detected on disable-wire"
|
||||
else
|
||||
let+ () =
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@ let verify_exchange_signing_key_validity ~key sk =
|
|||
}
|
||||
|
||||
let is_valid_at ~timestamp sk =
|
||||
Timestamp.geq sk.stamp_start timestamp && Timestamp.lt timestamp sk.stamp_end
|
||||
Timestamp.compare sk.stamp_start timestamp <= 0
|
||||
&& Timestamp.compare timestamp sk.stamp_end < 0
|
||||
|
|
|
|||
|
|
@ -97,10 +97,6 @@ module Timestamp = struct
|
|||
let never = uint64_max
|
||||
let zero = 0L
|
||||
let compare = Int64.unsigned_compare
|
||||
let gt a b = compare a b > 0
|
||||
let geq a b = compare a b >= 0
|
||||
let lt a b = compare a b < 0
|
||||
let leq a b = compare a b <= 0
|
||||
let equal a b = compare a b = 0
|
||||
let min a b = if compare a b < 0 then a else b
|
||||
let max a b = if compare a b > 0 then a else b
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ module Timestamp : sig
|
|||
val never : t
|
||||
val zero : t
|
||||
val compare : t -> t -> int
|
||||
val gt : t -> t -> bool
|
||||
val geq : t -> t -> bool
|
||||
val lt : t -> t -> bool
|
||||
val leq : t -> t -> bool
|
||||
val equal : t -> t -> bool
|
||||
val min : t -> t -> t
|
||||
val max : t -> t -> t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue