secmod_rsa: use denom_hash

This commit is contained in:
swrup 2026-02-24 17:23:03 +01:00
parent fa5d0ae75d
commit 4f473c003a
3 changed files with 45 additions and 50 deletions

View file

@ -18,6 +18,7 @@ type t = {
let make_denom_group_sorted denominations =
let open Syntax in
(* use hashtbl to re-group denoms *)
let ht = Hashtbl.create 0xff in
List.iter
(fun coin ->
@ -63,15 +64,14 @@ let make_denom_group_sorted denominations =
lost= None;
}
in
let+ l =
match Hashtbl.find_opt ht k with
| None ->
Error "denomination does not match any coin in configuration"
| Some l -> Ok l
in
Hashtbl.replace ht k (v :: l))
match Hashtbl.find_opt ht k with
| None -> Error "denomination does not match any coin in configuration"
| Some l ->
Hashtbl.replace ht k (v :: l);
Ok ())
denominations
in
let l = Hashtbl.to_seq ht |> List.of_seq in
(* ! important for /keys .exchange_sig
each group must be ordered in _reverse_ chronological order
@ -84,6 +84,7 @@ let make_denom_group_sorted denominations =
let cmp_denom b a = Timestamp.compare a.stamp_start b.stamp_start in
let cmp_group =
let cmp_amount a b =
(* TODO amount *)
let open Amount in
match Int64.unsigned_compare a.value b.value with
| 0 -> Int32.unsigned_compare a.fraction b.fraction
@ -92,8 +93,7 @@ let make_denom_group_sorted denominations =
fun (Rsa a) (Rsa b) -> cmp_amount a.value b.value
in
let l =
Hashtbl.to_seq ht
|> List.of_seq
l
|> List.map
(fun
((value, fee_withdraw, fee_deposit, fee_refresh, fee_refund), denoms)