This commit is contained in:
parent
4913d8ca76
commit
2f1c8c7bd2
8 changed files with 47 additions and 16 deletions
|
|
@ -1 +1 @@
|
||||||
{"start_date":{"t_s":1234.5},"end_date":{"t_s":99999999.900000006},"history_fee":"EUR:0.00","account_fee":"EUR:0.00","purse_fee":"EUR:0.00","history_expiration":{"t_s":9999999000000},"purse_account_limit":1,"purse_timeout":{"t_s":9999999000000},"master_sig":"C3XVRW8E4NRFRHETFY6F44PTYDEK8S35RFR5RR690A21HAK7T6P9KBBGXBD87T0XQ0MPQMTDJFT14MJZSHND3XEB8HQ7FQETVXNM008="}
|
{"start_date":{"t_s":0},"end_date":{"t_s":99999999.900000006},"history_fee":"EUR:0.00","account_fee":"EUR:0.00","purse_fee":"EUR:0.00","history_expiration":{"t_s":9999999000000},"purse_account_limit":1,"purse_timeout":{"t_s":9999999000000},"master_sig":"EHBTKAC30EYD2NGYB76B7JPG1VREYP4W3EQB6YQJJ41NHFWQSX9HQJXTZR9N65V6HAJB5KKHXAYTNBWBDJBE4YV38W6FGZYG6595E00="}
|
||||||
|
|
@ -190,9 +190,9 @@ let mk_keys ~db_conn (module Sm : Secmod.S) ~last_issue_date =
|
||||||
sign_f ~f:(Sm.sign_with_signkey ~pub:exchange_pub) R.{ list_issue_date; hc }
|
sign_f ~f:(Sm.sign_with_signkey ~pub:exchange_pub) R.{ list_issue_date; hc }
|
||||||
in
|
in
|
||||||
|
|
||||||
let recoup = (* todo /recoup *) [] in
|
let recoup = (* TODO /recoup *) [] in
|
||||||
let* global_fees =
|
let* global_fees =
|
||||||
Pg.get_global_fees db_conn ~start_date:None |> unwrap_err_caqti
|
Pg.get_global_fees db_conn ~start_date:Timestamp.epoch |> unwrap_err_caqti
|
||||||
in
|
in
|
||||||
let auditors = (* TODO *) [] in
|
let auditors = (* TODO *) [] in
|
||||||
let extensions = None in
|
let extensions = None in
|
||||||
|
|
|
||||||
|
|
@ -462,12 +462,28 @@ module Global_fees = struct
|
||||||
in
|
in
|
||||||
match global_fees with
|
match global_fees with
|
||||||
| [] ->
|
| [] ->
|
||||||
let+ () = Pg.insert_global_fee db_conn v |> unwrap_err_caqti in
|
let+ () = Pg.insert_global_fees db_conn v |> unwrap_err_caqti in
|
||||||
|
Logs.info (fun m -> m "added global fees");
|
||||||
()
|
()
|
||||||
| _l -> Error "global-fees already setup"
|
| [ vv ] -> (
|
||||||
|
match v.master_sig = vv.master_sig with
|
||||||
|
| false ->
|
||||||
|
Error
|
||||||
|
"a different global-fees was already setup for this time frame"
|
||||||
|
| true ->
|
||||||
|
Logs.info (fun m -> m "an identical global-fees was already setup");
|
||||||
|
Ok ())
|
||||||
|
| _ ->
|
||||||
|
Error
|
||||||
|
"invalid database state, multiple global-fees found in database for \
|
||||||
|
this time frame"
|
||||||
|
|
||||||
let jsont = GlobalFees.jsont
|
let jsont = GlobalFees.jsont
|
||||||
|
|
||||||
|
(* TODO global_fees
|
||||||
|
ensure it is defined for the current time.
|
||||||
|
there should be only one global_fees for each moment in time
|
||||||
|
and once set for a timeframe, it should not change. *)
|
||||||
let f req server _env =
|
let f req server _env =
|
||||||
Logs.info (fun m -> m "POST /management/global-fees/");
|
Logs.info (fun m -> m "POST /management/global-fees/");
|
||||||
let sm = Vif.Server.device Devices.secmod server in
|
let sm = Vif.Server.device Devices.secmod server in
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
transaction
|
transaction
|
||||||
|
|
||||||
should check validity of signatures got from db, for /management at least *)
|
should check validity of signatures got from db, for /management at least *)
|
||||||
|
(* TODO time
|
||||||
|
fix comparison with timestamp footgun *)
|
||||||
|
|
||||||
module type CONN = Caqti_miou.CONNECTION
|
module type CONN = Caqti_miou.CONNECTION
|
||||||
|
|
||||||
|
|
@ -303,15 +305,15 @@ let get_global_fees_by_time =
|
||||||
fun (module Conn : CONN) ~start_date ~end_date ->
|
fun (module Conn : CONN) ~start_date ~end_date ->
|
||||||
Conn.collect_list get_global_fees_by_time (start_date, end_date)
|
Conn.collect_list get_global_fees_by_time (start_date, end_date)
|
||||||
|
|
||||||
let insert_global_fee =
|
let insert_global_fees =
|
||||||
let insert_global_fee =
|
let insert_global_fees =
|
||||||
Caqti_type.(global_fee ->. unit)
|
Caqti_type.(global_fee ->. unit)
|
||||||
"INSERT INTO global_fee (start_date, end_date, history_fee, account_fee, \
|
"INSERT INTO global_fee (start_date, end_date, history_fee, account_fee, \
|
||||||
purse_fee, history_expiration, purse_account_limit, purse_timeout, \
|
purse_fee, history_expiration, purse_account_limit, purse_timeout, \
|
||||||
master_sig) VALUES ($1, $2, ($3,$4), ($5,$6), ($7,$8), $9, $10, $11, \
|
master_sig) VALUES ($1, $2, ($3,$4), ($5,$6), ($7,$8), $9, $10, $11, \
|
||||||
$12)"
|
$12)"
|
||||||
in
|
in
|
||||||
fun (module Conn : CONN) v -> Conn.exec insert_global_fee v
|
fun (module Conn : CONN) v -> Conn.exec insert_global_fees v
|
||||||
|
|
||||||
let get_wire_timestamp =
|
let get_wire_timestamp =
|
||||||
let get_wire_timestamp =
|
let get_wire_timestamp =
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
type t = Ptime.t option
|
type t = Ptime.t option
|
||||||
type span = Ptime.Span.t option
|
type span = Ptime.Span.t option
|
||||||
|
|
||||||
|
let epoch = Some Ptime.epoch
|
||||||
|
|
||||||
let diff a b =
|
let diff a b =
|
||||||
match (a, b) with
|
match (a, b) with
|
||||||
| None, _ | _, None -> None
|
| None, _ | _, None -> None
|
||||||
|
|
@ -79,7 +81,7 @@ let decode_int64 i = if i = Int64.max_int then None else Some (ptime_of_int64 i)
|
||||||
let bin = Bin.map Bin.neint64 decode_int64 encode_int64
|
let bin = Bin.map Bin.neint64 decode_int64 encode_int64
|
||||||
let bin_nbo = Bin.map Bin.beint64 decode_int64 encode_int64
|
let bin_nbo = Bin.map Bin.beint64 decode_int64 encode_int64
|
||||||
|
|
||||||
let caqti : Ptime.t option Caqti_type.t =
|
let caqti : t Caqti_type.t =
|
||||||
let encode v = Ok (encode_int64 v) in
|
let encode v = Ok (encode_int64 v) in
|
||||||
let decode v = Ok (decode_int64 v) in
|
let decode v = Ok (decode_int64 v) in
|
||||||
Caqti_type.custom ~encode ~decode Caqti_type.int64
|
Caqti_type.custom ~encode ~decode Caqti_type.int64
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
(* TODO time
|
(* TODO time
|
||||||
uhuh!
|
uhuh!
|
||||||
need to be int64 for binary/pg round trip
|
need to be int64 for binary/pg round trip
|
||||||
|
really need to fix this module
|
||||||
really need to fix this module *)
|
don't use option for never/forever *)
|
||||||
|
|
||||||
type t = Ptime.t option
|
type t = Ptime.t option
|
||||||
type span = Ptime.Span.t option
|
type span = Ptime.Span.t option
|
||||||
|
|
@ -21,6 +21,7 @@ module Span : sig
|
||||||
val caqti : t Caqti_type.t
|
val caqti : t Caqti_type.t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
val epoch : t
|
||||||
val diff : t -> t -> span
|
val diff : t -> t -> span
|
||||||
val add_span_exn : t -> span -> t
|
val add_span_exn : t -> span -> t
|
||||||
val of_span_exn : span -> t
|
val of_span_exn : span -> t
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
dune exec offline -- download && \
|
set -e
|
||||||
dune exec offline -- sign && \
|
|
||||||
dune exec offline -- upload
|
file1="tmp_file1.json"
|
||||||
|
file2="tmp_file2.json"
|
||||||
|
file3="tmp_file3.json"
|
||||||
|
|
||||||
|
dune exec offline -- download --output $file1
|
||||||
|
dune exec offline -- sign --input $file1 --output $file2
|
||||||
|
dune exec offline -- upload --input $file2 --url "/management/keys"
|
||||||
|
dune exec offline -- global-fees --output $file3 --start_date "0.0" --end_date "99999999.9" --history_fee "EUR:0.0" --account_fee "EUR:0.0" --purse_fee "EUR:0.0" --history_expiration "9999999.0" --purse_account_limit 1 --purse_timeout "9999999.0"
|
||||||
|
dune exec offline -- upload --input $file3 --url "/management/global-fees"
|
||||||
|
|
||||||
|
rm $file1
|
||||||
|
rm $file2
|
||||||
|
rm $file3
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,6 @@ let revoke_signkey ~output ~master_key ~signkey =
|
||||||
let* () = write_file output s in
|
let* () = write_file output s in
|
||||||
Ok ()
|
Ok ()
|
||||||
|
|
||||||
[@@@ocaml.warning "-27"]
|
|
||||||
|
|
||||||
let global_fees ~output ~master_key ~start_date ~end_date ~history_fee
|
let global_fees ~output ~master_key ~start_date ~end_date ~history_fee
|
||||||
~account_fee ~purse_fee ~history_expiration ~purse_account_limit
|
~account_fee ~purse_fee ~history_expiration ~purse_account_limit
|
||||||
~purse_timeout =
|
~purse_timeout =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue