+ caqti global_fee
This commit is contained in:
parent
5b7c243f8c
commit
02de94af84
1 changed files with 60 additions and 7 deletions
67
src/pg.ml
67
src/pg.ml
|
|
@ -17,6 +17,7 @@ open Crypto
|
|||
open Bin_type
|
||||
open Api
|
||||
|
||||
(* TODO move some caqti types to its module *)
|
||||
module Caqti_type = struct
|
||||
include Caqti_type
|
||||
|
||||
|
|
@ -48,6 +49,59 @@ module Caqti_type = struct
|
|||
~decode:(fun s -> Api.decode (Jsont.list AccountRestriction.jsont) s)
|
||||
string
|
||||
|
||||
let global_fee =
|
||||
let master_sig = Bin_sig.GlobalFees.caqti in
|
||||
custom
|
||||
~encode:(fun
|
||||
GlobalFees.
|
||||
{
|
||||
start_date;
|
||||
end_date;
|
||||
history_fee;
|
||||
account_fee;
|
||||
purse_fee;
|
||||
history_expiration;
|
||||
purse_account_limit;
|
||||
purse_timeout;
|
||||
master_sig;
|
||||
}
|
||||
->
|
||||
Ok
|
||||
( start_date,
|
||||
end_date,
|
||||
history_fee,
|
||||
account_fee,
|
||||
purse_fee,
|
||||
history_expiration,
|
||||
purse_account_limit,
|
||||
purse_timeout,
|
||||
master_sig ))
|
||||
~decode:(fun
|
||||
( start_date,
|
||||
end_date,
|
||||
history_fee,
|
||||
account_fee,
|
||||
purse_fee,
|
||||
history_expiration,
|
||||
purse_account_limit,
|
||||
purse_timeout,
|
||||
master_sig )
|
||||
->
|
||||
Ok
|
||||
{
|
||||
start_date;
|
||||
end_date;
|
||||
history_fee;
|
||||
account_fee;
|
||||
purse_fee;
|
||||
history_expiration;
|
||||
purse_account_limit;
|
||||
purse_timeout;
|
||||
master_sig;
|
||||
})
|
||||
Caqti_type.(
|
||||
t9 time time amount amount amount time_span int32 time_span master_sig)
|
||||
|
||||
include struct
|
||||
(* alias for hash *)
|
||||
|
||||
|
|
@ -82,6 +136,7 @@ let preflight =
|
|||
in
|
||||
fun (module Conn : CONN) -> Syntax.list_iter (fun p -> Conn.exec p ()) l
|
||||
|
||||
(* TODO return type *)
|
||||
let lookup_signing_key =
|
||||
let lookup_signing_key =
|
||||
Caqti_type.(eddsa_pub ->? t3 time time time)
|
||||
|
|
@ -107,6 +162,7 @@ let activate_signing_key =
|
|||
Conn.exec insert_signkey
|
||||
(pub, stamp_start, stamp_expire, stamp_end, master_sig)
|
||||
|
||||
(* TODO return type *)
|
||||
let lookup_denomination_key =
|
||||
let lookup_denomination_key =
|
||||
Caqti_type.(
|
||||
|
|
@ -231,6 +287,7 @@ let disable_auditor =
|
|||
fun (module Conn : CONN) ~auditor_pub ~change_date ->
|
||||
Conn.exec update_auditor (auditor_pub, "", "", false, change_date)
|
||||
|
||||
(* TODO return type *)
|
||||
let lookup_wire_fee_by_time =
|
||||
let lookup_wire_fee_by_time =
|
||||
Caqti_type.(t3 wire_method time time ->? t2 amount amount)
|
||||
|
|
@ -260,13 +317,10 @@ let insert_wire_fee =
|
|||
|
||||
let lookup_global_fee_by_time =
|
||||
let lookup_global_fee_by_time =
|
||||
let global_fee =
|
||||
Caqti_type.(t6 amount amount amount time_span time_span int32)
|
||||
in
|
||||
Caqti_type.(t2 time time ->? global_fee)
|
||||
"SELECT (history_fee).*, (account_fee).*, (purse_fee).*, purse_timeout, \
|
||||
history_expiration, purse_account_limit FROM global_fee WHERE end_date \
|
||||
> $1 AND start_date < $2;"
|
||||
"SELECT start_date, end_date, (history_fee).*, (account_fee).*, \
|
||||
(purse_fee).*, history_expiration, purse_account_limit, purse_timeout, \
|
||||
master_sig FROM global_fee WHERE end_date > $1 AND start_date < $2;"
|
||||
in
|
||||
fun (module Conn : CONN) ~start_date ~end_date ->
|
||||
Conn.find_opt lookup_global_fee_by_time (start_date, end_date)
|
||||
|
|
@ -537,7 +591,6 @@ let get_global_fees =
|
|||
fun (module Conn : CONN) ~start_date ->
|
||||
Conn.collect_list get_global_fees start_date
|
||||
|
||||
(* TODO record types for some results *)
|
||||
(* TODO
|
||||
iterate_denominations
|
||||
iterate_active_signkeys
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue