This commit is contained in:
parent
5b7c243f8c
commit
cbc83d42d1
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 Bin_type
|
||||||
open Api
|
open Api
|
||||||
|
|
||||||
|
(* TODO move some caqti types to its module *)
|
||||||
module Caqti_type = struct
|
module Caqti_type = struct
|
||||||
include Caqti_type
|
include Caqti_type
|
||||||
|
|
||||||
|
|
@ -48,6 +49,59 @@ module Caqti_type = struct
|
||||||
~decode:(fun s -> Api.decode (Jsont.list AccountRestriction.jsont) s)
|
~decode:(fun s -> Api.decode (Jsont.list AccountRestriction.jsont) s)
|
||||||
string
|
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
|
include struct
|
||||||
(* alias for hash *)
|
(* alias for hash *)
|
||||||
|
|
||||||
|
|
@ -82,6 +136,7 @@ let preflight =
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) -> Syntax.list_iter (fun p -> Conn.exec p ()) l
|
fun (module Conn : CONN) -> Syntax.list_iter (fun p -> Conn.exec p ()) l
|
||||||
|
|
||||||
|
(* TODO return type *)
|
||||||
let lookup_signing_key =
|
let lookup_signing_key =
|
||||||
let lookup_signing_key =
|
let lookup_signing_key =
|
||||||
Caqti_type.(eddsa_pub ->? t3 time time time)
|
Caqti_type.(eddsa_pub ->? t3 time time time)
|
||||||
|
|
@ -107,6 +162,7 @@ let activate_signing_key =
|
||||||
Conn.exec insert_signkey
|
Conn.exec insert_signkey
|
||||||
(pub, stamp_start, stamp_expire, stamp_end, master_sig)
|
(pub, stamp_start, stamp_expire, stamp_end, master_sig)
|
||||||
|
|
||||||
|
(* TODO return type *)
|
||||||
let lookup_denomination_key =
|
let lookup_denomination_key =
|
||||||
let lookup_denomination_key =
|
let lookup_denomination_key =
|
||||||
Caqti_type.(
|
Caqti_type.(
|
||||||
|
|
@ -231,6 +287,7 @@ let disable_auditor =
|
||||||
fun (module Conn : CONN) ~auditor_pub ~change_date ->
|
fun (module Conn : CONN) ~auditor_pub ~change_date ->
|
||||||
Conn.exec update_auditor (auditor_pub, "", "", false, 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 =
|
||||||
let lookup_wire_fee_by_time =
|
let lookup_wire_fee_by_time =
|
||||||
Caqti_type.(t3 wire_method time time ->? t2 amount amount)
|
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 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)
|
Caqti_type.(t2 time time ->? global_fee)
|
||||||
"SELECT (history_fee).*, (account_fee).*, (purse_fee).*, purse_timeout, \
|
"SELECT start_date, end_date, (history_fee).*, (account_fee).*, \
|
||||||
history_expiration, purse_account_limit FROM global_fee WHERE end_date \
|
(purse_fee).*, history_expiration, purse_account_limit, purse_timeout, \
|
||||||
> $1 AND start_date < $2;"
|
master_sig FROM global_fee WHERE end_date > $1 AND start_date < $2;"
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) ~start_date ~end_date ->
|
fun (module Conn : CONN) ~start_date ~end_date ->
|
||||||
Conn.find_opt lookup_global_fee_by_time (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 ->
|
fun (module Conn : CONN) ~start_date ->
|
||||||
Conn.collect_list get_global_fees start_date
|
Conn.collect_list get_global_fees start_date
|
||||||
|
|
||||||
(* TODO record types for some results *)
|
|
||||||
(* TODO
|
(* TODO
|
||||||
iterate_denominations
|
iterate_denominations
|
||||||
iterate_active_signkeys
|
iterate_active_signkeys
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue