more work on auditordb plugin API
This commit is contained in:
parent
fa1ca946c9
commit
8bbcf86678
@ -262,6 +262,26 @@ postgres_create_tables (void *cls)
|
||||
",fee_refund_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table indicating up to which transactions the auditor has
|
||||
processed the exchange database. Used for SELECTing the
|
||||
statements to process. We basically trace the exchange's
|
||||
operations by the 5 primary tables: reserves_in,
|
||||
reserves_out, deposits, refresh_sessions and refunds. The
|
||||
other tables of the exchange DB just provide supporting
|
||||
evidence which is checked alongside the audit of these
|
||||
five tables. The 5 indices below include the last serial
|
||||
ID from the respective tables that we have processed. Thus,
|
||||
we need to select those table entries that are strictly
|
||||
larger (and process in monotonically increasing order). */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS auditor_progress"
|
||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||
",last_reserve_in_serial_id INT8 NOT NULL"
|
||||
",last_reserve_out_serial_id INT8 NOT NULL"
|
||||
",last_deposit_serial_id INT8 NOT NULL"
|
||||
",last_melt_serial_id INT8 NOT NULL"
|
||||
",last_refund_serial_id INT8 NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table with all of the customer reserves and their respective
|
||||
balances that the auditor is aware of.
|
||||
"last_reserve_out_serial_id" marks the last withdrawal from
|
||||
@ -269,7 +289,7 @@ postgres_create_tables (void *cls)
|
||||
and "last_reserve_in_serial_id" is the last "reserve_in"
|
||||
operation about this reserve that the auditor is aware of. */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS auditor_reserves"
|
||||
"(reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)"
|
||||
"(reserve_pub BYTEA NOT NULL CHECK(LENGTH(reserve_pub)=32)"
|
||||
",master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
",reserve_balance_val INT8 NOT NULL"
|
||||
",reserve_balance_frac INT4 NOT NULL"
|
||||
@ -282,10 +302,13 @@ postgres_create_tables (void *cls)
|
||||
",last_reserve_out_serial_id INT8 NOT NULL"
|
||||
")");
|
||||
|
||||
SQLEXEC_INDEX("CREATE INDEX auditor_reserves_by_reserve_pub "
|
||||
"ON auditor_reserves(reserve_pub)");
|
||||
|
||||
/* Table with the sum of the balances of all customer reserves
|
||||
(by exchange's master public key) */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS auditor_reserve_balance"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||
",reserve_balance_val INT8 NOT NULL"
|
||||
",reserve_balance_frac INT4 NOT NULL"
|
||||
",reserve_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
@ -302,7 +325,7 @@ postgres_create_tables (void *cls)
|
||||
of; "refund_serial_id" tells us the last entry in "refunds"
|
||||
for this denom_pub that the auditor is aware of. */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS denomination_pending"
|
||||
"(denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE"
|
||||
"(denom_pub_hash BYTEA PRIMARY KEY REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE"
|
||||
",denom_balance_val INT8 NOT NULL"
|
||||
",denom_balance_frac INT4 NOT NULL"
|
||||
",denom_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
@ -315,19 +338,20 @@ postgres_create_tables (void *cls)
|
||||
",refund_fee_balance_val INT8 NOT NULL"
|
||||
",refund_fee_balance_frac INT4 NOT NULL"
|
||||
",refund_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
",last_reserve_out_serial_id INT8 NOT NULL"
|
||||
",last_deposit_serial_id INT8 NOT NULL"
|
||||
",last_melt_serial_id INT8 NOT NULL"
|
||||
",last_refund INT8 NOT NULL"
|
||||
",last_refund_serial_id INT8 NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table with the sum of the outstanding coins from
|
||||
"denomination_pending" (denom_pubs must belong
|
||||
to the respective's exchange's master public key);
|
||||
it represents the total_liabilities of the exchange
|
||||
at this point (modulo unexpected historic_loss-style
|
||||
events where denomination keys are compromised) */
|
||||
"denomination_pending" (denom_pubs must belong to the
|
||||
respective's exchange's master public key); it represents the
|
||||
total_liabilities of the exchange at this point (modulo
|
||||
unexpected historic_loss-style events where denomination keys are
|
||||
compromised) */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS total_liabilities"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||
",denom_balance_val INT8 NOT NULL"
|
||||
",denom_balance_frac INT4 NOT NULL"
|
||||
",denom_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
@ -337,38 +361,38 @@ postgres_create_tables (void *cls)
|
||||
",melt_fee_balance_val INT8 NOT NULL"
|
||||
",melt_fee_balance_frac INT4 NOT NULL"
|
||||
",melt_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
",refund_fee_balance_val INT8 NOT NULL"
|
||||
",refund_fee_balance_frac INT4 NOT NULL"
|
||||
",refund_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table with the sum of the generated coins all
|
||||
denomination keys. This represents the maximum
|
||||
additional total financial risk of the exchange
|
||||
in case that all denomination keys are compromised
|
||||
(and all of the deposits so far were done by
|
||||
the successful attacker). So this is strictly an
|
||||
upper bound on the risk exposure of the exchange.
|
||||
(Note that this risk is in addition to the known
|
||||
total_liabilities) */
|
||||
/* Table with the sum of the generated coins all denomination keys.
|
||||
This represents the maximum additional total financial risk of
|
||||
the exchange in case that all denomination keys are compromised
|
||||
(and all of the deposits so far were done by the successful
|
||||
attacker). So this is strictly an upper bound on the risk
|
||||
exposure of the exchange. (Note that this risk is in addition to
|
||||
the known total_liabilities.) */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS total_risk"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||
",risk_val INT8 NOT NULL"
|
||||
",risk_frac INT4 NOT NULL"
|
||||
",risk_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
|
||||
/* Table with historic profits; basically, when a denom_pub
|
||||
is expired and everything associated with it is garbage
|
||||
collected, the final profits end up in here; note that
|
||||
the "denom_pub" here is not a foreign key, we just keep
|
||||
it as a reference point. "revenue_balance" is the sum
|
||||
of all of the profits we made on the coin except for
|
||||
withdraw fees (which are in historic_reserve_revenue);
|
||||
the deposit and melt fees are given individually; the
|
||||
delta to the revenue_balance is from coins that were withdrawn
|
||||
but never deposited prior to expiration. */
|
||||
/* Table with historic profits; basically, when a denom_pub has
|
||||
expired and everything associated with it is garbage collected,
|
||||
the final profits end up in here; note that the "denom_pub" here
|
||||
is not a foreign key, we just keep it as a reference point.
|
||||
"revenue_balance" is the sum of all of the profits we made on the
|
||||
coin except for withdraw fees (which are in
|
||||
historic_reserve_revenue); the deposit, melt and refund fees are given
|
||||
individually; the delta to the revenue_balance is from coins that
|
||||
were withdrawn but never deposited prior to expiration. */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS historic_denomination_revenue"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
",denom_pub_hash BYTEA NOT NULL CHECK (LENGTH(denom_pub_hash)=64)"
|
||||
",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)"
|
||||
",revenue_timestamp INT8 NOT NULL"
|
||||
",revenue_balance_val INT8 NOT NULL"
|
||||
",revenue_balance_frac INT4 NOT NULL"
|
||||
@ -378,7 +402,11 @@ postgres_create_tables (void *cls)
|
||||
",deposit_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
",melt_fee_balance_val INT8 NOT NULL"
|
||||
",melt_fee_balance_frac INT4 NOT NULL"
|
||||
",melt_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ")");
|
||||
",melt_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
",refund_fee_balance_val INT8 NOT NULL"
|
||||
",refund_fee_balance_frac INT4 NOT NULL"
|
||||
",refund_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ")");
|
||||
|
||||
|
||||
/* Table with historic losses; basically, when we need to
|
||||
invalidate a denom_pub because the denom_priv was
|
||||
@ -387,25 +415,13 @@ postgres_create_tables (void *cls)
|
||||
implemented, so right now this table is not used.) */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS historic_losses"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
",denom_pub_hash BYTEA NOT NULL CHECK (LENGTH(denom_pub_hash)=64)"
|
||||
",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)"
|
||||
",loss_timestamp INT8 NOT NULL"
|
||||
",loss_balance_val INT8 NOT NULL"
|
||||
",loss_balance_frac INT4 NOT NULL"
|
||||
",loss_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table with historic profits by reserve; basically, when a
|
||||
reserve expires, we transmit the balance back to the user, but
|
||||
rounding gains and withdraw fees are listed here. */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS historic_reserve_revenue"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
",reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32)"
|
||||
",expiration_date INT8 NOT NULL"
|
||||
",reserve_profit_val INT8 NOT NULL"
|
||||
",reserve_profit_frac INT4 NOT NULL"
|
||||
",reserve_profit_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
/* Table with historic profits from reserves; we eventually
|
||||
GC "historic_reserve_revenue", and then store the totals
|
||||
in here (by time intervals). */
|
||||
@ -418,12 +434,22 @@ postgres_create_tables (void *cls)
|
||||
",reserve_profits_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
SQLEXEC_INDEX("CREATE INDEX historic_reserve_summary_by_master_pub_start_date"
|
||||
" ON historic_ledger(master_pub,start_date)");
|
||||
|
||||
|
||||
/* Table with historic business ledger; basically, when the exchange
|
||||
operator decides to use operating costs for anything but wire
|
||||
transfers to merchants, it goes in here. This happens when the
|
||||
operator users transaction fees for business expenses. "purpose"
|
||||
is free-form but should be a human-readable wire transfer
|
||||
identifier. */
|
||||
identifier. This is NOT yet used and outside of the scope of
|
||||
the core auditing logic. However, once we do take fees to use
|
||||
operating costs, and if we still want "predicted_result" to match
|
||||
the tables overall, we'll need a command-line tool to insert rows
|
||||
into this table and update "predicted_result" accordingly.
|
||||
(So this table for now just exists as a reminder of what we'll
|
||||
need in the long term.) */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS historic_ledger"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
",purpose VARCHAR NOT NULL"
|
||||
@ -433,20 +459,21 @@ postgres_create_tables (void *cls)
|
||||
",balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
SQLEXEC_INDEX("CREATE INDEX history_ledger_by_master_pub_and_time "
|
||||
"ON historic_ledger(master_pub,timestamp)");
|
||||
|
||||
/* Table with the sum of the ledger, historic_revenue,
|
||||
historic_losses and the auditor_reserve_balance.
|
||||
This is the final amount that the exchange should have
|
||||
in its bank account right now. */
|
||||
historic_losses and the auditor_reserve_balance. This is the
|
||||
final amount that the exchange should have in its bank account
|
||||
right now. */
|
||||
SQLEXEC ("CREATE TABLE IF NOT EXISTS predicted_result"
|
||||
"(master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32)"
|
||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||
",balance_val INT8 NOT NULL"
|
||||
",balance_frac INT4 NOT NULL"
|
||||
",balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
|
||||
")");
|
||||
|
||||
|
||||
SQLEXEC_INDEX("CREATE INDEX testx "
|
||||
"ON test(test_pub)");
|
||||
#undef SQLEXEC
|
||||
#undef SQLEXEC_INDEX
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <jansson.h>
|
||||
#include <gnunet/gnunet_util_lib.h>
|
||||
#include "taler_auditordb_lib.h"
|
||||
#include "taler_signatures.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -36,6 +37,9 @@ struct TALER_AUDITORDB_Session;
|
||||
/**
|
||||
* @brief The plugin API, returned from the plugin's "init" function.
|
||||
* The argument given to "init" is simply a configuration handle.
|
||||
*
|
||||
* Functions starting with "get_" return one result, functions starting
|
||||
* with "select_" return multiple results via callbacks.
|
||||
*/
|
||||
struct TALER_AUDITORDB_Plugin
|
||||
{
|
||||
@ -129,6 +133,594 @@ struct TALER_AUDITORDB_Plugin
|
||||
int
|
||||
(*gc) (void *cls);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about a denomination key and in particular
|
||||
* the properties (value, fees, expiration times) the coins signed
|
||||
* with this key have.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param issue issuing information with value, fees and other info about the denomination
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_denomination_info)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_DenominationKeyValidityPS *issue);
|
||||
|
||||
|
||||
/**
|
||||
* Get information about denomination keys of a particular exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param cb function to call with the results
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*select_denomination_info)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
void *cb, /* FIXME: type! */
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about a reserve. There must not be an
|
||||
* existing record for the reserve.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param reserve_pub public key of the reserve
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param reserve_balance amount stored in the reserve
|
||||
* @param withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @param expiration_date expiration date of the reserve
|
||||
* @param last_reserve_in_serial_id up to which point did we consider
|
||||
* incoming transfers for the above information
|
||||
* @param last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_reserve_info)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *reserve_balance,
|
||||
const struct TALER_Amount *withdraw_fee_balance,
|
||||
struct GNUNET_TIME_Absolute expiration_date,
|
||||
uint64_t last_reserve_in_serial_id,
|
||||
uint64_t last_reserve_out_serial_id);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about a reserve. Destructively updates an
|
||||
* existing record, which must already exist.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param reserve_pub public key of the reserve
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param reserve_balance amount stored in the reserve
|
||||
* @param withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @param expiration_date expiration date of the reserve
|
||||
* @param last_reserve_in_serial_id up to which point did we consider
|
||||
* incoming transfers for the above information
|
||||
* @param last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_reserve_info)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *reserve_balance,
|
||||
const struct TALER_Amount *withdraw_fee_balance,
|
||||
struct GNUNET_TIME_Absolute expiration_date,
|
||||
uint64_t last_reserve_in_serial_id,
|
||||
uint64_t last_reserve_out_serial_id);
|
||||
|
||||
|
||||
/**
|
||||
* Get information about a reserve.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param reserve_pub public key of the reserve
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param[out] reserve_balance amount stored in the reserve
|
||||
* @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @param[out] expiration_date expiration date of the reserve
|
||||
* @param[out] last_reserve_in_serial_id up to which point did we consider
|
||||
* incoming transfers for the above information
|
||||
* @param[out] last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_NO if there is no known
|
||||
* record about this reserve; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*get_reserve_info)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct TALER_Amount *reserve_balance,
|
||||
struct TALER_Amount *withdraw_fee_balance,
|
||||
struct GNUNET_TIME_Absolute *expiration_date,
|
||||
uint64_t *last_reserve_in_serial_id,
|
||||
uint64_t *last_reserve_out_serial_id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about all reserves. There must not be an
|
||||
* existing record for the @a master_pub.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param reserve_balance amount stored in the reserve
|
||||
* @param withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_reserve_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *reserve_balance,
|
||||
const struct TALER_Amount *withdraw_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about all reserves. Destructively updates an
|
||||
* existing record, which must already exist.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param reserve_balance amount stored in the reserve
|
||||
* @param withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_reserve_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *reserve_balance,
|
||||
const struct TALER_Amount *withdraw_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Get summary information about all reserves.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master public key of the exchange
|
||||
* @param[out] reserve_balance amount stored in the reserve
|
||||
* @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
|
||||
* due to withdrawals from this reserve
|
||||
* @return #GNUNET_OK on success; #GNUNET_NO if there is no known
|
||||
* record about this exchange; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*get_reserve_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct TALER_Amount *reserve_balance,
|
||||
struct TALER_Amount *withdraw_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about a denomination key's balances. There
|
||||
* must not be an existing record for the denomination key.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param denom_pub_hash hash of the denomination public key
|
||||
* @param denom_balance value of coins outstanding with this denomination key
|
||||
* @param deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param melt_fee_balance total melt fees collected for this DK
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @param last_deposit_serial_id up to which point did we consider
|
||||
* deposits for the above information
|
||||
* @param last_melt_serial_id up to which point did we consider
|
||||
* melts for the above information
|
||||
* @param last_refund_serial_id up to which point did we consider
|
||||
* refunds for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_denomination_balance)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct GNUNET_HashCode *denom_pub_hash,
|
||||
const struct TALER_Amount *denom_balance,
|
||||
const struct TALER_Amount *deposit_fee_balance,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
uint64_t last_reserve_out_serial_id,
|
||||
uint64_t last_deposit_serial_id,
|
||||
uint64_t last_melt_serial_id,
|
||||
uint64_t last_refund_serial_id);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about a denomination key's balances. There
|
||||
* must be an existing record for the denomination key.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param denom_pub_hash hash of the denomination public key
|
||||
* @param denom_balance value of coins outstanding with this denomination key
|
||||
* @param deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param melt_fee_balance total melt fees collected for this DK
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @param last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @param last_deposit_serial_id up to which point did we consider
|
||||
* deposits for the above information
|
||||
* @param last_melt_serial_id up to which point did we consider
|
||||
* melts for the above information
|
||||
* @param last_refund_serial_id up to which point did we consider
|
||||
* refunds for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_denomination_balance)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct GNUNET_HashCode *denom_pub_hash,
|
||||
const struct TALER_Amount *denom_balance,
|
||||
const struct TALER_Amount *deposit_fee_balance,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance,
|
||||
uint64_t last_reserve_out_serial_id,
|
||||
uint64_t last_deposit_serial_id,
|
||||
uint64_t last_melt_serial_id,
|
||||
uint64_t last_refund_serial_id);
|
||||
|
||||
|
||||
/**
|
||||
* Get information about a denomination key's balances.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param denom_pub_hash hash of the denomination public key
|
||||
* @param[out] denom_balance value of coins outstanding with this denomination key
|
||||
* @param[out] deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param[out] melt_fee_balance total melt fees collected for this DK
|
||||
* @param[out] refund_fee_balance total refund fees collected for this DK
|
||||
* @param[out] last_reserve_out_serial_id up to which point did we consider
|
||||
* withdrawals for the above information
|
||||
* @param[out] last_deposit_serial_id up to which point did we consider
|
||||
* deposits for the above information
|
||||
* @param[out] last_melt_serial_id up to which point did we consider
|
||||
* melts for the above information
|
||||
* @param[out] last_refund_serial_id up to which point did we consider
|
||||
* refunds for the above information
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*get_denomination_balance)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct GNUNET_HashCode *denom_pub_hash,
|
||||
struct TALER_Amount *denom_balance,
|
||||
struct TALER_Amount *deposit_fee_balance,
|
||||
struct TALER_Amount *melt_fee_balance,
|
||||
struct TALER_Amount *refund_fee_balance,
|
||||
uint64_t *last_reserve_out_serial_id,
|
||||
uint64_t *last_deposit_serial_id,
|
||||
uint64_t *last_melt_serial_id,
|
||||
uint64_t *last_refund_serial_id);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about an exchange's denomination balances. There
|
||||
* must not be an existing record for the exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param denom_balance value of coins outstanding with this denomination key
|
||||
* @param deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param melt_fee_balance total melt fees collected for this DK
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_denomination_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *denom_balance,
|
||||
const struct TALER_Amount *deposit_fee_balance,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about an exchange's denomination balances. There
|
||||
* must be an existing record for the exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param denom_balance value of coins outstanding with this denomination key
|
||||
* @param deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param melt_fee_balance total melt fees collected for this DK
|
||||
* @param refund_fee_balance total refund fees collected for this DK
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_denomination_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *denom_balance,
|
||||
const struct TALER_Amount *deposit_fee_balance,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Get information about an exchange's denomination balances.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param[out] denom_balance value of coins outstanding with this denomination key
|
||||
* @param[out] deposit_fee_balance total deposit fees collected for this DK
|
||||
* @param[out] melt_fee_balance total melt fees collected for this DK
|
||||
* @param[out] refund_fee_balance total refund fees collected for this DK
|
||||
* @return #GNUNET_OK on success; #GNUNET_NO if there is no entry
|
||||
* for this @a master_pub; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*get_denomination_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct TALER_Amount *denom_balance,
|
||||
struct TALER_Amount *deposit_fee_balance,
|
||||
struct TALER_Amount *melt_fee_balance,
|
||||
struct TALER_Amount *refund_fee_balance);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about an exchange's risk exposure. There
|
||||
* must not be an existing record for the exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_risk_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *risk);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about an exchange's risk exposure. There
|
||||
* must be an existing record for the exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param risk maximum risk exposure of the exchange
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_risk_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *risk);
|
||||
|
||||
|
||||
/**
|
||||
* Get information about an exchange's risk exposure.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param[out] risk maximum risk exposure of the exchange
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure;
|
||||
* #GNUNET_NO if we have no records for the @a master_pub
|
||||
*/
|
||||
int
|
||||
(*get_risk_summary)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct TALER_Amount *risk);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about an exchange's historic
|
||||
* revenue about a denomination key.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param denom_pub_hash hash of the denomination key
|
||||
* @param revenue_timestamp when did this profit get realized
|
||||
* @param revenue_balance what was the total profit made from
|
||||
* deposit fees, melting fees, refresh fees
|
||||
* and coins that were never returned?
|
||||
* @param deposit_fee_balance total profits from deposit fees
|
||||
* @param melt_fee_balance total profits from melting fees
|
||||
* @param refund_fee_balance total profits from refund fees
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_historic_denom_revenue)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct GNUNET_HashCode *denom_pub_hash,
|
||||
struct GNUNET_TIME_Absolute revenue_timestamp,
|
||||
const struct TALER_Amount *revenue_balance,
|
||||
const struct TALER_Amount *deposit_fee_balance,
|
||||
const struct TALER_Amount *melt_fee_balance,
|
||||
const struct TALER_Amount *refund_fee_balance);
|
||||
|
||||
/**
|
||||
* Obtain all of the historic denomination key revenue
|
||||
* of the given @a master_pub.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param cb function to call with the results
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*select_historic_denom_revnue)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
void *cb, /* FIXME: fix type */
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about an exchange's historic
|
||||
* losses (from compromised denomination keys).
|
||||
*
|
||||
* Note yet used, need to implement exchange's bankrupcy
|
||||
* protocol (and tables!) first.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param denom_pub_hash hash of the denomination key
|
||||
* @param loss_timestamp when did this profit get realized
|
||||
* @param loss_balance what was the total loss
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_historic_losses)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct GNUNET_HashCode *denom_pub_hash,
|
||||
struct GNUNET_TIME_Absolute loss_timestamp,
|
||||
const struct TALER_Amount *loss_balance);
|
||||
|
||||
/**
|
||||
* Obtain all of the historic denomination key losses
|
||||
* of the given @a master_pub.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param cb function to call with the results
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*select_historic_losses)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
void *cb, /* FIXME: fix type */
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about an exchange's historic revenue from reserves.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param start_time beginning of aggregated time interval
|
||||
* @param end_time end of aggregated time interval
|
||||
* @param reserve_profits total profits made
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_historic_reserve_revenue)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct GNUNET_TIME_Absolute start_time,
|
||||
struct GNUNET_TIME_Absolute end_time,
|
||||
const struct TALER_Amount *reserve_profits);
|
||||
|
||||
|
||||
/**
|
||||
* Return information about an exchange's historic revenue from reserves.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param cb function to call with results
|
||||
* @param cb_cls closure for @a cb
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*select_historic_reserve_revenue)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
void *cb, /* FIXME: type */
|
||||
void *cb_cls);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Insert information about the predicted exchange's bank
|
||||
* account balance.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param balance what the bank account balance of the exchange should show
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*insert_predicted_result)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *balance);
|
||||
|
||||
|
||||
/**
|
||||
* Update information about an exchange's predicted balance. There
|
||||
* must be an existing record for the exchange.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param balance what the bank account balance of the exchange should show
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
(*update_predicted_result)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
const struct TALER_Amount *balance);
|
||||
|
||||
|
||||
/**
|
||||
* Get an exchange's predicted balance.
|
||||
*
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param master_pub master key of the exchange
|
||||
* @param[out] balance expected bank account balance of the exchange
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure;
|
||||
* #GNUNET_NO if we have no records for the @a master_pub
|
||||
*/
|
||||
int
|
||||
(*get_predicted_balance)(void *cls,
|
||||
struct TALER_AUDITORDB_Session *session,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct TALER_Amount *balance);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -756,7 +756,7 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
* @param cls the @e cls of this struct with the plugin-specific state
|
||||
* @param session connection to use
|
||||
* @param denom_pub the public key used for signing coins of this denomination
|
||||
* @param issue issuing information with value, fees and other info about the coin
|
||||
* @param issue issuing information with value, fees and other info about the denomination
|
||||
* @return #GNUNET_OK on success; #GNUNET_SYSERR on failure
|
||||
*/
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user