diff --git a/src/http_info.ml b/src/http_info.ml index e2f5ee73..9ddce7a5 100644 --- a/src/http_info.ml +++ b/src/http_info.ml @@ -73,22 +73,23 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date = let denom_l = (* if `?last_issue_date` query param does not exactly match the `stamp_start` of one of the denomination keys, all keys are returned *) - match last_issue_date with - | None -> denom_l - | Some last_issue_date -> ( - match - List.find_opt + let stamp_start_opt = + match last_issue_date with + | None -> None + | Some timestamp -> + List.find_map (fun v -> - Timestamp.compare v.Denomination.stamp_start last_issue_date = 0) + if Timestamp.compare v.Denomination.stamp_start timestamp = 0 then + Some v.stamp_start + else None) denom_l - with - | None -> denom_l - | Some _ -> - List.filter - (fun v -> - Timestamp.compare v.Denomination.stamp_start last_issue_date - >= 0) - denom_l) + in + match stamp_start_opt with + | None -> denom_l + | Some timestamp -> + List.filter + (fun v -> Timestamp.compare v.Denomination.stamp_start timestamp >= 0) + denom_l in let* denominations = Denomination.make_denom_group denom_l in @@ -108,9 +109,8 @@ let mk_keys ~db_conn (module Keys : Keys.S) ~last_issue_date = | sk :: _ -> sk.SignKey.key in let exchange_sig = - (* Compact EdDSA signature (binary-only) over the - contatentation of all of the master_sigs (in reverse - chronological order by group) in the arrays under "denominations". *) + (* Compact eddsa signature over the contatentation of all of the master_sigs + (in reverse chronological order by group) in the arrays under "denominations" *) let hc = denom_l |> List.map (fun dn -> dn.Denomination.master_sig)