wip wire-fee & global-fees
This commit is contained in:
parent
af09c697b8
commit
0e46ea162a
5 changed files with 212 additions and 9 deletions
82
src/pg.ml
82
src/pg.ml
|
|
@ -32,6 +32,9 @@ module Caqti_type = struct
|
|||
let eddsa_pub = EddsaPublicKey.caqti
|
||||
let eddsa_sig = EddsaSignature.caqti
|
||||
|
||||
(* todo: enum type for wire_method? *)
|
||||
let wire_method = Caqti_type.string
|
||||
|
||||
include struct
|
||||
(* alias for hash *)
|
||||
|
||||
|
|
@ -183,8 +186,7 @@ let insert_signkey_revocation =
|
|||
let lookup_auditor_timestamp =
|
||||
let lookup_auditor_timestamp =
|
||||
Caqti_type.(eddsa_pub ->? time)
|
||||
"lookup_auditor_timestamp SELECT last_change FROM auditors WHERE \
|
||||
auditor_pub=$1"
|
||||
"SELECT last_change FROM auditors WHERE auditor_pub=$1"
|
||||
in
|
||||
fun (module Conn : CONN) auditor_pub ->
|
||||
Conn.find_opt lookup_auditor_timestamp auditor_pub
|
||||
|
|
@ -218,3 +220,79 @@ let update_auditor =
|
|||
->
|
||||
Conn.exec update_auditor
|
||||
(auditor_pub, auditor_url, auditor_name, enabled, change_date)
|
||||
|
||||
let lookup_wire_fee_by_time =
|
||||
let lookup_wire_fee_by_time =
|
||||
Caqti_type.(t3 wire_method time time ->? t2 amount amount)
|
||||
"SELECT (wire_fee).*, (closing_fee).* FROM wire_fee WHERE wire_method=$1 \
|
||||
AND end_date > $2 AND start_date < $3"
|
||||
in
|
||||
fun (module Conn : CONN) ~wire_method ~start_date ~end_date ->
|
||||
Conn.find_opt lookup_wire_fee_by_time (wire_method, start_date, end_date)
|
||||
|
||||
let insert_wire_fee =
|
||||
let insert_wire_fee =
|
||||
let master_sig = Bin_sig.MasterWireFee.caqti in
|
||||
Caqti_type.(t6 wire_method time time amount amount master_sig ->. unit)
|
||||
"INSERT INTO wire_fee (wire_method, start_date, end_date, wire_fee, \
|
||||
closing_fee, master_sig) VALUES ($1, $2, $3, ($4,$5), ($6,$7), $8)"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
~wire_method
|
||||
~start_date
|
||||
~end_date
|
||||
~wire_fee
|
||||
~closing_fee
|
||||
~master_sig
|
||||
->
|
||||
Conn.exec insert_wire_fee
|
||||
(wire_method, start_date, end_date, wire_fee, closing_fee, master_sig)
|
||||
|
||||
let lookup_global_fee_by_time =
|
||||
let lookup_global_fee_by_time =
|
||||
let global_fee = Caqti_type.(t6 amount amount amount time time 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;"
|
||||
in
|
||||
fun (module Conn : CONN) ~start_date ~end_date ->
|
||||
Conn.find_opt lookup_global_fee_by_time (start_date, end_date)
|
||||
|
||||
let insert_global_fee =
|
||||
let insert_global_fee =
|
||||
let master_sig = Bin_sig.GlobalFees.caqti in
|
||||
Caqti_type.(
|
||||
t9 time time amount amount amount time time int32 master_sig ->. unit)
|
||||
"INSERT INTO global_fee (start_date, end_date, history_fee, account_fee, \
|
||||
purse_fee, purse_timeout, history_expiration, purse_account_limit, \
|
||||
master_sig) VALUES ($1, $2, ($3,$4), ($5,$6), ($7,$8), $9, $10, $11, \
|
||||
$12)"
|
||||
in
|
||||
fun (module Conn : CONN)
|
||||
Api.GlobalFees.
|
||||
{
|
||||
start_date;
|
||||
end_date;
|
||||
history_fee;
|
||||
account_fee;
|
||||
purse_fee;
|
||||
history_expiration= _;
|
||||
purse_account_limit;
|
||||
purse_timeout= _;
|
||||
master_sig;
|
||||
}
|
||||
->
|
||||
(* TODO time *)
|
||||
let purse_timeout = None in
|
||||
let history_expiration = None in
|
||||
Conn.exec insert_global_fee
|
||||
( start_date,
|
||||
end_date,
|
||||
history_fee,
|
||||
account_fee,
|
||||
purse_fee,
|
||||
purse_timeout,
|
||||
history_expiration,
|
||||
purse_account_limit,
|
||||
master_sig )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue