aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c9
-rw-r--r--src/auditor/taler-helper-auditor-coins.c9
-rw-r--r--src/auditor/taler-helper-auditor-deposits.c8
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c8
-rw-r--r--src/auditor/taler-helper-auditor-wire.c8
-rw-r--r--src/exchangedb/exchange-0002.sql11
-rw-r--r--src/include/taler_exchangedb_plugin.h121
7 files changed, 163 insertions, 11 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index f3f65ffb3..5a144ddf9 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -116,6 +116,11 @@ static json_t *report_bad_sig_losses;
*/
static struct TALER_Amount total_bad_sig_loss;
+/**
+ * Should we run checks that only work for exchange-internal audits?
+ */
+static int internal_checks;
+
/**
* Report a (serious) inconsistency in the exchange's database with
@@ -1462,6 +1467,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('i',
+ "internal",
+ "perform checks only applicable for exchange-internal audits",
+ &internal_checks),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index a63426f7a..bceb04198 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -193,6 +193,11 @@ struct CoinHistory
*/
static struct CoinHistory coin_histories[MAX_COIN_HISTORIES];
+/**
+ * Should we run checks that only work for exchange-internal audits?
+ */
+static int internal_checks;
+
/**
* Return the index we should use for @a coin_pub in #coin_histories.
@@ -2742,6 +2747,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('i',
+ "internal",
+ "perform checks only applicable for exchange-internal audits",
+ &internal_checks),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
index b9c4ff8de..1c0128319 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -51,6 +51,10 @@ static json_int_t number_missed_deposit_confirmations;
*/
static struct TALER_Amount total_missed_deposit_confirmations;
+/**
+ * Should we run checks that only work for exchange-internal audits?
+ */
+static int internal_checks;
/**
* Closure for #test_dc.
@@ -343,6 +347,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('i',
+ "internal",
+ "perform checks only applicable for exchange-internal audits",
+ &internal_checks),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index 8f7921fa8..8b49f747c 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -142,6 +142,10 @@ static json_t *report_bad_sig_losses;
*/
static struct TALER_Amount total_bad_sig_loss;
+/**
+ * Should we run checks that only work for exchange-internal audits?
+ */
+static int internal_checks;
/* ***************************** Report logic **************************** */
@@ -1660,6 +1664,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('i',
+ "internal",
+ "perform checks only applicable for exchange-internal audits",
+ &internal_checks),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",
diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c
index 1facd2155..128eba812 100644
--- a/src/auditor/taler-helper-auditor-wire.c
+++ b/src/auditor/taler-helper-auditor-wire.c
@@ -314,6 +314,10 @@ static struct GNUNET_CURL_Context *ctx;
*/
static struct GNUNET_CURL_RescheduleContext *rc;
+/**
+ * Should we run checks that only work for exchange-internal audits?
+ */
+static int internal_checks;
/* ***************************** Shutdown **************************** */
@@ -2166,6 +2170,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('i',
+ "internal",
+ "perform checks only applicable for exchange-internal audits",
+ &internal_checks),
GNUNET_GETOPT_option_base32_auto ('m',
"exchange-key",
"KEY",
diff --git a/src/exchangedb/exchange-0002.sql b/src/exchangedb/exchange-0002.sql
index f0e191a3b..a7b6b815e 100644
--- a/src/exchangedb/exchange-0002.sql
+++ b/src/exchangedb/exchange-0002.sql
@@ -98,17 +98,6 @@ ALTER TABLE reserves_close
DROP COLUMN reserve_pub;
--- "reserves" has no BIGSERIAL because it is a 'mutable' table
--- the auditor recomputes these balances itself
--- => verify_reserve_balance check only done for 'internal' auditor
--- "deposits" is updated with 'tiny' and 'done' bits
--- => those SHALL NOT to be used by the (external) auditor!
--- "prewire" is updated with 'finished' and 'failed' bits, but
--- those are of no concern for the auditor (prewire is not auditable!)
--- "auditors" is updated with 'is_active' and 'last_change', but
--- those are of no concern for the auditor
-
-
CREATE TABLE IF NOT EXISTS auditors
(auditor_uuid BIGSERIAL UNIQUE
,auditor_pub BYTEA PRIMARY KEY CHECK (LENGTH(auditor_pub)=32)
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index feca61fe3..8cbdc70cc 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -77,6 +77,73 @@ GNUNET_NETWORK_STRUCT_END
/**
+ * Enumeration of all of the tables replicated by exchange-auditor
+ * database replication.
+ */
+enum TALER_EXCHANGEDB_ReplicatedTable
+{
+
+ /**
+ * The "denominations" table.
+ */
+ TALER_EXCHANGEDB_RT_DENOMINATIONS,
+
+ // FIXME...
+
+};
+
+
+/**
+ * Record of a single entry in a replicated table.
+ */
+struct TALER_EXCHANGEDB_TableData
+{
+ /**
+ * Data of which table is returned here?
+ */
+ enum TALER_EXCHANGEDB_ReplicatedTable table;
+
+ /**
+ * Serial number of the record.
+ */
+ uint64_t serial;
+
+ /**
+ * Table-specific details.
+ */
+ union
+ {
+
+ /**
+ * Details from the 'denominations' table.
+ */
+ struct
+ {
+ // FIXME...
+ } denominations;
+
+ // FIXME...
+
+ } details;
+
+};
+
+
+/**
+ * Function called on data to replicate in the auditor's database.
+ *
+ * @param cls closure
+ * @param td record from an exchange table
+ * @return #GNUNET_OK to continue to iterate,
+ * #GNUNET_SYSERR to fail with an error
+ */
+typedef int
+(*TALER_EXCHANGEDB_ReplicationCallback)(
+ void *cls,
+ const struct TALER_EXCHANGEDB_TableData *td);
+
+
+/**
* @brief All information about a denomination key (which is used to
* sign coins into existence).
*/
@@ -3499,6 +3566,60 @@ struct TALER_EXCHANGEDB_Plugin
struct TALER_Amount *closing_fee);
+ /**
+ * Lookup the latest serial number of @a table. Used in
+ * exchange-auditor database replication.
+ *
+ * @param cls closure
+ * @param session a session
+ * @param table table for which we should return the serial
+ * @param[out] latest serial number in use
+ * @return transaction status code, GNUNET_DB_STATUS_HARD_ERROR if
+ * @a table does not have a serial number
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_serial_by_table)(void *cls,
+ struct TALER_EXCHANGEDB_Session *session,
+ enum TALER_EXCHANGEDB_ReplicatedTable table,
+ uint64_t *serial);
+
+ /**
+ * Lookup records above @a serial number in @a table. Used in
+ * exchange-auditor database replication.
+ *
+ * @param cls closure
+ * @param session a session
+ * @param table table for which we should return the serial
+ * @param serial largest serial number to exclude
+ * @param cb function to call on the records
+ * @param cb_cls closure for @a cb
+ * @return transaction status code, GNUNET_DB_STATUS_HARD_ERROR if
+ * @a table does not have a serial number
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_records_by_table)(void *cls,
+ struct TALER_EXCHANGEDB_Session *session,
+ enum TALER_EXCHANGEDB_ReplicatedTable table,
+ uint64_t serial,
+ TALER_EXCHANGEDB_ReplicationCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Insert record set into @a table. Used in exchange-auditor database
+ * replication.
+ *
+ * @param cls closure
+ * @param session a session
+ * @param tb table data to insert
+ * @return transaction status code, GNUNET_DB_STATUS_HARD_ERROR if
+ * @a table does not have a serial number
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_records_by_table)(void *cls,
+ struct TALER_EXCHANGEDB_Session *session,
+ const struct TALER_EXCHANGEDB_TableData *td);
+
};
#endif /* _TALER_EXCHANGE_DB_H */