update auditordb API to support logic for taler-wire-auditor
This commit is contained in:
parent
34db060b4c
commit
96e04d33e1
@ -78,9 +78,9 @@ static struct TALER_AUDITORDB_Session *asession;
|
|||||||
static struct TALER_MasterPublicKeyP master_pub;
|
static struct TALER_MasterPublicKeyP master_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last reserve_in serial ID seen.
|
* Last reserve_in / reserve_out serial IDs seen.
|
||||||
*/
|
*/
|
||||||
static struct TALER_AUDITORDB_ProgressPoint pp;
|
static struct TALER_AUDITORDB_WireProgressPoint pp;
|
||||||
|
|
||||||
|
|
||||||
/* ***************************** Report logic **************************** */
|
/* ***************************** Report logic **************************** */
|
||||||
@ -192,7 +192,7 @@ incremental_processing (Analysis analysis,
|
|||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
enum GNUNET_DB_QueryStatus qsx;
|
enum GNUNET_DB_QueryStatus qsx;
|
||||||
|
|
||||||
qsx = adb->get_auditor_progress (adb->cls,
|
qsx = adb->get_wire_auditor_progress (adb->cls,
|
||||||
asession,
|
asession,
|
||||||
&master_pub,
|
&master_pub,
|
||||||
&pp);
|
&pp);
|
||||||
@ -209,14 +209,9 @@ incremental_processing (Analysis analysis,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
_("Resuming audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n"),
|
_("Resuming audit at %llu/%llu\n"),
|
||||||
(unsigned long long) pp.last_reserve_in_serial_id,
|
(unsigned long long) pp.last_reserve_in_serial_id,
|
||||||
(unsigned long long) pp.last_reserve_out_serial_id,
|
(unsigned long long) pp.last_reserve_out_serial_id);
|
||||||
(unsigned long long) pp.last_withdraw_serial_id,
|
|
||||||
(unsigned long long) pp.last_deposit_serial_id,
|
|
||||||
(unsigned long long) pp.last_melt_serial_id,
|
|
||||||
(unsigned long long) pp.last_refund_serial_id,
|
|
||||||
(unsigned long long) pp.last_wire_out_serial_id);
|
|
||||||
}
|
}
|
||||||
qs = analysis (analysis_cls);
|
qs = analysis (analysis_cls);
|
||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
@ -230,12 +225,12 @@ incremental_processing (Analysis analysis,
|
|||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx)
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx)
|
||||||
qs = adb->update_auditor_progress (adb->cls,
|
qs = adb->update_wire_auditor_progress (adb->cls,
|
||||||
asession,
|
asession,
|
||||||
&master_pub,
|
&master_pub,
|
||||||
&pp);
|
&pp);
|
||||||
else
|
else
|
||||||
qs = adb->insert_auditor_progress (adb->cls,
|
qs = adb->insert_wire_auditor_progress (adb->cls,
|
||||||
asession,
|
asession,
|
||||||
&master_pub,
|
&master_pub,
|
||||||
&pp);
|
&pp);
|
||||||
@ -247,14 +242,9 @@ incremental_processing (Analysis analysis,
|
|||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
_("Concluded audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n\n"),
|
_("Concluded audit step at %llu/%llu\n"),
|
||||||
(unsigned long long) pp.last_reserve_in_serial_id,
|
(unsigned long long) pp.last_reserve_in_serial_id,
|
||||||
(unsigned long long) pp.last_reserve_out_serial_id,
|
(unsigned long long) pp.last_reserve_out_serial_id);
|
||||||
(unsigned long long) pp.last_withdraw_serial_id,
|
|
||||||
(unsigned long long) pp.last_deposit_serial_id,
|
|
||||||
(unsigned long long) pp.last_melt_serial_id,
|
|
||||||
(unsigned long long) pp.last_refund_serial_id,
|
|
||||||
(unsigned long long) pp.last_wire_out_serial_id);
|
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,15 +218,17 @@ postgres_create_tables (void *cls)
|
|||||||
larger (and process in monotonically increasing order). */
|
larger (and process in monotonically increasing order). */
|
||||||
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress"
|
GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress"
|
||||||
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
"(master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)"
|
||||||
",last_reserve_in_serial_id INT8 NOT NULL"
|
",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_reserve_out_serial_id INT8 NOT NULL"
|
",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_reserve_payback_serial_id INT8 NOT NULL"
|
",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_reserve_close_serial_id INT8 NOT NULL"
|
",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_withdraw_serial_id INT8 NOT NULL"
|
",last_withdraw_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_deposit_serial_id INT8 NOT NULL"
|
",last_deposit_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_melt_serial_id INT8 NOT NULL"
|
",last_melt_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_refund_serial_id INT8 NOT NULL"
|
",last_refund_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
",last_wire_out_serial_id INT8 NOT NULL"
|
",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
|
",last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
|
",last_wire_reserve_out_serial_id INT8 NOT NULL DEFAULT 0"
|
||||||
")"),
|
")"),
|
||||||
/* Table with all of the customer reserves and their respective
|
/* Table with all of the customer reserves and their respective
|
||||||
balances that the auditor is aware of.
|
balances that the auditor is aware of.
|
||||||
@ -508,6 +510,29 @@ postgres_prepare (PGconn *db_conn)
|
|||||||
" FROM auditor_progress"
|
" FROM auditor_progress"
|
||||||
" WHERE master_pub=$1;",
|
" WHERE master_pub=$1;",
|
||||||
1),
|
1),
|
||||||
|
/* Used in #postgres_insert_wire_auditor_progress() */
|
||||||
|
GNUNET_PQ_make_prepare ("wire_auditor_progress_insert",
|
||||||
|
"INSERT INTO auditor_progress "
|
||||||
|
"(master_pub"
|
||||||
|
",last_wire_reserve_in_serial_id"
|
||||||
|
",last_wire_reserve_out_serial_id"
|
||||||
|
") VALUES ($1,$2,$3);",
|
||||||
|
3),
|
||||||
|
/* Used in #postgres_update_wire_auditor_progress() */
|
||||||
|
GNUNET_PQ_make_prepare ("wire_auditor_progress_update",
|
||||||
|
"UPDATE auditor_progress SET "
|
||||||
|
" last_wire_reserve_in_serial_id=$1"
|
||||||
|
",last_wire_reserve_out_serial_id=$2"
|
||||||
|
" WHERE master_pub=$3",
|
||||||
|
3),
|
||||||
|
/* Used in #postgres_get_wire_auditor_progress() */
|
||||||
|
GNUNET_PQ_make_prepare ("wire_auditor_progress_select",
|
||||||
|
"SELECT"
|
||||||
|
" last_wire_reserve_in_serial_id"
|
||||||
|
",last_wire_reserve_out_serial_id"
|
||||||
|
" FROM auditor_progress"
|
||||||
|
" WHERE master_pub=$1;",
|
||||||
|
1),
|
||||||
/* Used in #postgres_insert_reserve_info() */
|
/* Used in #postgres_insert_reserve_info() */
|
||||||
GNUNET_PQ_make_prepare ("auditor_reserves_insert",
|
GNUNET_PQ_make_prepare ("auditor_reserves_insert",
|
||||||
"INSERT INTO auditor_reserves "
|
"INSERT INTO auditor_reserves "
|
||||||
@ -1294,6 +1319,98 @@ postgres_get_auditor_progress (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @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 pp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
postgres_insert_wire_auditor_progress (void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (session->conn,
|
||||||
|
"wire_auditor_progress_insert",
|
||||||
|
params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the auditor. 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 pp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
postgres_update_wire_auditor_progress (void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_query_param_uint64 (&pp->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (session->conn,
|
||||||
|
"wire_auditor_progress_update",
|
||||||
|
params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the auditor.
|
||||||
|
*
|
||||||
|
* @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] pp set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
postgres_get_wire_auditor_progress (void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_WireProgressPoint *pp)
|
||||||
|
{
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_pub),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_in_serial_id",
|
||||||
|
&pp->last_reserve_in_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id",
|
||||||
|
&pp->last_reserve_out_serial_id),
|
||||||
|
GNUNET_PQ_result_spec_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
|
||||||
|
"wire_auditor_progress_select",
|
||||||
|
params,
|
||||||
|
rs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert information about a reserve. There must not be an
|
* Insert information about a reserve. There must not be an
|
||||||
* existing record for the reserve.
|
* existing record for the reserve.
|
||||||
@ -2453,6 +2570,10 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
|
|||||||
plugin->update_auditor_progress = &postgres_update_auditor_progress;
|
plugin->update_auditor_progress = &postgres_update_auditor_progress;
|
||||||
plugin->insert_auditor_progress = &postgres_insert_auditor_progress;
|
plugin->insert_auditor_progress = &postgres_insert_auditor_progress;
|
||||||
|
|
||||||
|
plugin->get_wire_auditor_progress = &postgres_get_wire_auditor_progress;
|
||||||
|
plugin->update_wire_auditor_progress = &postgres_update_wire_auditor_progress;
|
||||||
|
plugin->insert_wire_auditor_progress = &postgres_insert_wire_auditor_progress;
|
||||||
|
|
||||||
plugin->del_reserve_info = &postgres_del_reserve_info;
|
plugin->del_reserve_info = &postgres_del_reserve_info;
|
||||||
plugin->get_reserve_info = &postgres_get_reserve_info;
|
plugin->get_reserve_info = &postgres_get_reserve_info;
|
||||||
plugin->update_reserve_info = &postgres_update_reserve_info;
|
plugin->update_reserve_info = &postgres_update_reserve_info;
|
||||||
|
@ -106,6 +106,24 @@ typedef int
|
|||||||
const struct TALER_Amount *reserve_profits);
|
const struct TALER_Amount *reserve_profits);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure for remembering the wire auditor's progress over the
|
||||||
|
* various tables and (auditor) transactions.
|
||||||
|
*/
|
||||||
|
struct TALER_AUDITORDB_WireProgressPoint
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* last_reserve_in_serial_id serial ID of the last reserve_in transfer the wire auditor processed
|
||||||
|
*/
|
||||||
|
uint64_t last_reserve_in_serial_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* last_reserve_out_serial_id serial ID of the last reserve_out the wire auditor processed
|
||||||
|
*/
|
||||||
|
uint64_t last_reserve_out_serial_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure for remembering the auditor's progress over the
|
* Structure for remembering the auditor's progress over the
|
||||||
* various tables and (auditor) transactions.
|
* various tables and (auditor) transactions.
|
||||||
@ -351,6 +369,56 @@ struct TALER_AUDITORDB_Plugin
|
|||||||
struct TALER_AUDITORDB_ProgressPoint *pp);
|
struct TALER_AUDITORDB_ProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert information about the wire auditor's progress with an exchange's
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @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 pp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
(*insert_wire_auditor_progress)(void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update information about the progress of the wire auditor. 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 pp where is the auditor in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
(*update_wire_auditor_progress)(void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
const struct TALER_AUDITORDB_WireProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about the progress of the wire auditor.
|
||||||
|
*
|
||||||
|
* @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] pp set to where the auditor is in processing
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
(*get_wire_auditor_progress)(void *cls,
|
||||||
|
struct TALER_AUDITORDB_Session *session,
|
||||||
|
const struct TALER_MasterPublicKeyP *master_pub,
|
||||||
|
struct TALER_AUDITORDB_WireProgressPoint *pp);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert information about a reserve. There must not be an
|
* Insert information about a reserve. There must not be an
|
||||||
* existing record for the reserve.
|
* existing record for the reserve.
|
||||||
|
Loading…
Reference in New Issue
Block a user