(* TODO be sure to not use postgres ptime add a dune stanza like for prelude: "(flags (:standard -open Prelude))" *) module Caqti_type = struct include Caqti_type (* we want to use int64 timestamps, not postgresql built-in timestamp type *) let ptime : Ptime.t Caqti_type.t = let encode i = Ok (Util.ptime_to_int64 i) in let decode = Util.ptime_of_int64 in Caqti_type.custom ~encode ~decode Caqti_type.(int64) end (*open Crypto*) open Bin_type let amount_t : Amount.t Caqti_type.t = let open Amount in Caqti_type.custom ~encode:(fun amount -> Ok (amount.value, amount.fraction)) ~decode:(fun (value, fraction) -> Amount.make ~sign:None ~currency:Config.currency ~value ~fraction) Caqti_type.(t2 int64 int32) let master_signature_t : MasterSignatureP.t Caqti_type.t = let open MasterSignatureP in Caqti_type.custom ~encode:(fun master_sig -> Ok (to_string master_sig)) ~decode:(fun s -> of_string s) Caqti_type.string (* WIP: minimum db functions for basic /management *) let pg_todo () = assert false open Caqti_request.Infix (* signkey *) (* todo: - what type to use for TALER_ExchangePublicKeyP + TALER_EXCHANGEDB_SignkeyMetaData -> I think it could be something = to FutureSignKey.t - master signature: over smthing? *) let activate_signing_key _cls (exchange_public_key : Signkey.t) = let open Bin_type in let _exchange_pub = ExchangePublicKeyP.(to_string (of_value exchange_public_key.pub)) in let _master_sig = exchange_public_key.master_sig |> Option.get |> MasterSignatureP.to_string in let _insert_signkey = Caqti_type.(t5 string ptime ptime ptime string ->! int) "INSERT INTO exchange_sign_keys (exchange_pub, valid_from, expire_sign, \ expire_legal, master_sig) VALUES ($1, $2, $3, $4, $5);" in pg_todo () (* enum GNUNET_DB_QueryStatus TEH_PG_activate_signing_key ( void *cls, const struct TALER_ExchangePublicKeyP *exchange_pub, const struct TALER_EXCHANGEDB_SignkeyMetaData *meta, const struct TALER_MasterSignatureP *master_sig) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam iparams[] = { GNUNET_PQ_query_param_auto_from_type (exchange_pub), GNUNET_PQ_query_param_timestamp (&meta->start), GNUNET_PQ_query_param_timestamp (&meta->expire_sign), GNUNET_PQ_query_param_timestamp (&meta->expire_legal), GNUNET_PQ_query_param_auto_from_type (master_sig), GNUNET_PQ_query_param_end }; } *) (* ----- *) let lookup_signing_key = pg_todo let iterate_active_signkeys = pg_todo let insert_signkey_revocation = pg_todo let lookup_signkey_revocation = pg_todo (* denominations *) let insert_denomination_info = pg_todo let get_denomination_info = pg_todo let get_denomination_by_serial = pg_todo let iterate_denomination_info = pg_todo let iterate_denominations = pg_todo let get_coin_denomination = pg_todo let insert_denomination_revocation = pg_todo let get_denomination_revocation = pg_todo let lookup_denomination_key = pg_todo let add_denomination_key = pg_todo