add get_denominations + get_active_signkeys
This commit is contained in:
parent
477dd2230b
commit
2f8f7496bd
1 changed files with 27 additions and 18 deletions
45
src/pg.ml
45
src/pg.ml
|
|
@ -44,12 +44,25 @@ let find_signkey =
|
||||||
Caqti_type.(eddsa_pub ->? signkey_data)
|
Caqti_type.(eddsa_pub ->? signkey_data)
|
||||||
"SELECT exchange_pub, valid_from, expire_sign, expire_legal, \
|
"SELECT exchange_pub, valid_from, expire_sign, expire_legal, \
|
||||||
exchange_sign_keys.master_sig, signkey_revocations.master_sig FROM \
|
exchange_sign_keys.master_sig, signkey_revocations.master_sig FROM \
|
||||||
exchange_sign_keys WHERE exchange_pub=$1\n\
|
exchange_sign_keys WHERE exchange_pub=$1 LEFT JOIN signkey_revocations \
|
||||||
\ LEFT JOIN signkey_revocations USING (esk_serial)"
|
USING (esk_serial)"
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) (exchange_pub : EddsaPublicKey.t) ->
|
fun (module Conn : CONN) (exchange_pub : EddsaPublicKey.t) ->
|
||||||
Conn.find_opt find_signkey exchange_pub
|
Conn.find_opt find_signkey exchange_pub
|
||||||
|
|
||||||
|
let get_active_signkeys =
|
||||||
|
let get_active_signkeys =
|
||||||
|
Caqti_type.(time ->* signkey_data)
|
||||||
|
"SELECT exchange_pub, valid_from, expire_sign, expire_legal, \
|
||||||
|
exchange_sign_keys.master_sig, signkey_revocations.master_sig FROM \
|
||||||
|
exchange_sign_keys esk WHERE expire_sign > $1 AND NOT EXISTS (SELECT \
|
||||||
|
esk_serial FROM signkey_revocations skr WHERE esk.esk_serial = \
|
||||||
|
skr.esk_serial)"
|
||||||
|
in
|
||||||
|
fun (module Conn : CONN) () ->
|
||||||
|
let now = Ptime_clock.now () |> Option.some in
|
||||||
|
Conn.collect_list get_active_signkeys now
|
||||||
|
|
||||||
(* note: does not update revocation *)
|
(* note: does not update revocation *)
|
||||||
let insert_signkey =
|
let insert_signkey =
|
||||||
let insert_signkey =
|
let insert_signkey =
|
||||||
|
|
@ -71,6 +84,18 @@ let find_denom =
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) h_denom_pub -> Conn.find_opt find_denom h_denom_pub
|
fun (module Conn : CONN) h_denom_pub -> Conn.find_opt find_denom h_denom_pub
|
||||||
|
|
||||||
|
let get_denominations =
|
||||||
|
let get_denominations =
|
||||||
|
Caqti_type.(unit ->* denom_data)
|
||||||
|
"SELECT denom_pub, (coin).*, valid_from, expire_withdraw, \
|
||||||
|
expire_deposit, expire_legal, (fee_withdraw).*, (fee_deposit).*, \
|
||||||
|
(fee_refresh).*, (fee_refund).*, age_mask, denom_pub_hash, \
|
||||||
|
denominations.master_sig, denomination_revocations.master_sig FROM \
|
||||||
|
denominations LEFT JOIN denomination_revocations USING \
|
||||||
|
(denominations_serial)"
|
||||||
|
in
|
||||||
|
fun (module Conn : CONN) -> Conn.collect_list get_denominations ()
|
||||||
|
|
||||||
(* note: does not update revocation *)
|
(* note: does not update revocation *)
|
||||||
let insert_denom =
|
let insert_denom =
|
||||||
let insert_denom =
|
let insert_denom =
|
||||||
|
|
@ -293,23 +318,7 @@ let insert_partner =
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) v -> Conn.exec insert_partner v
|
fun (module Conn : CONN) v -> Conn.exec insert_partner v
|
||||||
|
|
||||||
(*
|
|
||||||
let get_denominations =
|
|
||||||
let get_denominations =
|
|
||||||
Caqti_type.(unit ->* denom_data)
|
|
||||||
"SELECT denominations_serial, denominations.master_sig, \
|
|
||||||
denom_revocations_serial_id IS NOT NULL AS revoked, valid_from, \
|
|
||||||
expire_withdraw, expire_deposit, expire_legal, coin, fee_withdraw, \
|
|
||||||
fee_deposit, fee_refresh, fee_refund, denom_type, age_mask, denom_pub \
|
|
||||||
FROM denominations LEFT JOIN denomination_revocations USING \
|
|
||||||
(denominations_serial)"
|
|
||||||
in
|
|
||||||
fun (module Conn : CONN) -> Conn.collect_list get_denominations ()
|
|
||||||
*)
|
|
||||||
|
|
||||||
(* TODO
|
(* TODO
|
||||||
iterate_denominations
|
|
||||||
iterate_active_signkeys
|
|
||||||
iterate_auditor_denominations
|
iterate_auditor_denominations
|
||||||
iterate_active_auditors
|
iterate_active_auditors
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue