[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated (cc5c8a53c -> c96c2f1ac)
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated (cc5c8a53c -> c96c2f1ac) |
Date: |
Fri, 23 Aug 2024 10:58:36 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository exchange.
from cc5c8a53c integrate auditor SPA
new a9900856e fix DB transaction logic of wire-credit auditor helper
new c96c2f1ac add missing file
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/auditor/taler-helper-auditor-wire-credit.c | 147 +++++++++++----------
src/auditordb/Makefile.am | 3 +-
contrib/sigp/h.header => src/auditordb/pg_helper.c | 35 +++--
3 files changed, 105 insertions(+), 80 deletions(-)
copy contrib/sigp/h.header => src/auditordb/pg_helper.c (51%)
diff --git a/src/auditor/taler-helper-auditor-wire-credit.c
b/src/auditor/taler-helper-auditor-wire-credit.c
index 3f19de9a3..0ccb68a3f 100644
--- a/src/auditor/taler-helper-auditor-wire-credit.c
+++ b/src/auditor/taler-helper-auditor-wire-credit.c
@@ -40,6 +40,12 @@
*/
#define GRACE_PERIOD GNUNET_TIME_UNIT_HOURS
+/**
+ * Maximum number of wire transfers we process per
+ * (database) transaction.
+ */
+#define MAX_PER_TRANSACTION 1024
+
/**
* How much do we allow the bank and the exchange to disagree about
* timestamps? Should be sufficiently large to avoid bogus reports from deltas
@@ -314,6 +320,15 @@ do_shutdown (void *cls)
}
+/**
+ * Start the database transactions and begin the audit.
+ *
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+begin_transaction (void);
+
+
/**
* Commit the transaction, checkpointing our progress in the auditor DB.
*
@@ -322,9 +337,21 @@ do_shutdown (void *cls)
static void
commit (enum GNUNET_DB_QueryStatus qs)
{
- if (qs >= 0)
- {
- qs = TALER_ARL_adb->update_balance (
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Transaction logic ended with status %d\n",
+ qs);
+ if (qs < 0)
+ goto handle_db_error;
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (total_wire_in),
+ TALER_ARL_SET_AB (total_bad_amount_in_plus),
+ TALER_ARL_SET_AB (total_bad_amount_in_minus),
+ TALER_ARL_SET_AB (total_misattribution_in),
+ TALER_ARL_SET_AB (total_wire_format_amount),
+ NULL);
+ if (0 <= qs)
+ qs = TALER_ARL_adb->insert_balance (
TALER_ARL_adb->cls,
TALER_ARL_SET_AB (total_wire_in),
TALER_ARL_SET_AB (total_bad_amount_in_plus),
@@ -332,28 +359,8 @@ commit (enum GNUNET_DB_QueryStatus qs)
TALER_ARL_SET_AB (total_misattribution_in),
TALER_ARL_SET_AB (total_wire_format_amount),
NULL);
- if (0 <= qs)
- qs = TALER_ARL_adb->insert_balance (
- TALER_ARL_adb->cls,
- TALER_ARL_SET_AB (total_wire_in),
- TALER_ARL_SET_AB (total_bad_amount_in_plus),
- TALER_ARL_SET_AB (total_bad_amount_in_minus),
- TALER_ARL_SET_AB (total_misattribution_in),
- TALER_ARL_SET_AB (total_wire_format_amount),
- NULL);
- if (0 > qs)
- {
- if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Serialization issue, not recording progress\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Hard error, not recording progress\n");
- TALER_ARL_adb->rollback (TALER_ARL_adb->cls);
- TALER_ARL_edb->rollback (TALER_ARL_edb->cls);
- return;
- }
- }
+ if (0 > qs)
+ goto handle_db_error;
for (struct WireAccount *wa = wa_head;
NULL != wa;
wa = wa->next)
@@ -374,43 +381,46 @@ commit (enum GNUNET_DB_QueryStatus qs)
wa->wire_off_in,
NULL);
if (0 > qs)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Failed to update auditor DB, not recording progress\n");
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- return;
- }
+ goto handle_db_error;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Transaction ends at %s=%llu for account `%s'\n",
+ wa->label_reserve_in_serial_id,
+ (unsigned long long) wa->last_reserve_in_serial_id,
+ wa->ai->section_name);
}
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls);
+ if (0 > qs)
{
- qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls);
- if (0 > qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Exchange DB commit failed, rolling back transaction\n");
- TALER_ARL_adb->rollback (TALER_ARL_adb->cls);
- }
- else
- {
- qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls);
- if (0 > qs)
- {
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Auditor DB commit failed!\n");
- }
- }
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Exchange DB commit failed, rolling back transaction\n");
+ goto handle_db_error;
}
- else
+ qs = TALER_ARL_adb->commit (TALER_ARL_adb->cls);
+ if (0 > qs)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Processing failed, rolling back transaction\n");
- TALER_ARL_adb->rollback (TALER_ARL_adb->cls);
- TALER_ARL_edb->rollback (TALER_ARL_edb->cls);
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ goto handle_db_error;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Transaction concluded!\n");
if (1 == test_mode)
GNUNET_SCHEDULER_shutdown ();
+ return;
+handle_db_error:
+ TALER_ARL_adb->rollback (TALER_ARL_adb->cls);
+ TALER_ARL_edb->rollback (TALER_ARL_edb->cls);
+ for (unsigned int max_retries = 3; max_retries>0; max_retries--)
+ {
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ break;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Serialization issue, trying again\n");
+ qs = begin_transaction ();
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Hard database error, terminating\n");
+ GNUNET_SCHEDULER_shutdown ();
}
@@ -422,6 +432,7 @@ commit (enum GNUNET_DB_QueryStatus qs)
static void
conclude_credit_history (void)
{
+ // FIXME: what about entries that are left in in_map?
if (NULL != in_map)
{
GNUNET_CONTAINER_multihashmap_destroy (in_map);
@@ -614,7 +625,8 @@ analyze_credit (
GNUNET_assert (TALER_BANK_CT_RESERVE ==
credit_details->type);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Analyzing bank CREDIT at %s of %s with Reserve-pub %s\n",
+ "Analyzing bank CREDIT #%llu at %s of %s with Reserve-pub %s\n",
+ (unsigned long long) credit_details->serial_id,
GNUNET_TIME_timestamp2s (credit_details->execution_date),
TALER_amount2s (&credit_details->amount),
TALER_B2S (&credit_details->details.reserve.reserve_pub));
@@ -625,6 +637,8 @@ analyze_credit (
&key);
if (NULL == rii)
{
+ // FIXME: probably should instead add to
+ // auditor DB and report missing! (& continue!)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Failed to find wire transfer at `%s' in exchange database.
Audit ends at this point in time.\n",
GNUNET_TIME_timestamp2s (credit_details->execution_date));
@@ -838,8 +852,8 @@ process_credits (void *cls)
enum GNUNET_DB_QueryStatus qs;
/* skip accounts where CREDIT is not enabled */
- while ((NULL != wa) &&
- (GNUNET_NO == wa->ai->credit_enabled))
+ while ( (NULL != wa) &&
+ (GNUNET_NO == wa->ai->credit_enabled) )
wa = wa->next;
if (NULL == wa)
{
@@ -873,12 +887,10 @@ process_credits (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"pass `%s'\n",
wa->ai->auth->details.basic.password);
- // NOTE: handle the case where more than INT32_MAX transactions exist.
- // (CG: used to be INT64_MAX, changed by MS to INT32_MAX, why? To be
discussed with him!)
wa->chh = TALER_BANK_credit_history (ctx,
wa->ai->auth,
wa->wire_off_in,
- INT32_MAX,
+ MAX_PER_TRANSACTION,
GNUNET_TIME_UNIT_ZERO,
&history_credit_cb,
wa);
@@ -908,11 +920,6 @@ begin_credit_audit (void)
}
-/**
- * Start the database transactions and begin the audit.
- *
- * @return transaction status code
- */
static enum GNUNET_DB_QueryStatus
begin_transaction (void)
{
@@ -942,7 +949,7 @@ begin_transaction (void)
TALER_ARL_edb->preflight (TALER_ARL_edb->cls);
if (GNUNET_OK !=
TALER_ARL_edb->start (TALER_ARL_edb->cls,
- "wire auditor"))
+ "wire credit auditor"))
{
GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR;
@@ -992,7 +999,13 @@ begin_transaction (void)
return qs;
}
wa->start_reserve_in_serial_id = wa->last_reserve_in_serial_id;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Starting from reserve_in at %s=%llu for account `%s'\n",
+ wa->label_reserve_in_serial_id,
+ (unsigned long long) wa->start_reserve_in_serial_id,
+ wa->ai->section_name);
}
+
begin_credit_audit ();
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
diff --git a/src/auditordb/Makefile.am b/src/auditordb/Makefile.am
index 36c6917a8..d4bb7f171 100644
--- a/src/auditordb/Makefile.am
+++ b/src/auditordb/Makefile.am
@@ -59,7 +59,8 @@ endif
# MARK: CRUD
libtaler_plugin_auditordb_postgres_la_SOURCES = \
- plugin_auditordb_postgres.c pg_helper.h \
+ plugin_auditordb_postgres.c \
+ pg_helper.h pg_helper.c \
pg_delete_deposit_confirmations.c pg_delete_deposit_confirmations.h \
pg_delete_pending_deposit.c pg_delete_pending_deposit.h \
pg_delete_purse_info.c pg_delete_purse_info.h \
diff --git a/contrib/sigp/h.header b/src/auditordb/pg_helper.c
similarity index 51%
copy from contrib/sigp/h.header
copy to src/auditordb/pg_helper.c
index 6ed22a63d..f022d8e57 100644
--- a/contrib/sigp/h.header
+++ b/src/auditordb/pg_helper.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2022 Taler Systems SA
+ Copyright (C) 2015, 2016 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -14,18 +14,29 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file taler_signatures.h
- * @brief message formats and signature constants used to define
- * the binary formats of signatures in Taler
- * @author Florian Dold
- * @author Benedikt Mueller
- *
- * This file should define the constants and C structs that one needs
- * to know to implement Taler clients (wallets or merchants or
- * auditor) that need to produce or verify Taler signatures.
+ * @file auditordb/auditordb_plugin.c
+ * @brief Logic to load database plugin
+ * @author Christian Grothoff
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
-#ifndef TALER_SIGNATURES_H
-#define TALER_SIGNATURES_H
+#include "platform.h"
+#include "taler_auditordb_plugin.h"
+#include <ltdl.h>
+const char *
+TAH_PG_get_table_name (enum TALER_AUDITORDB_SuppressableTables table)
+{
+ const char *tables[] = {
+ "auditor_amount_arithmetic_inconsistency",
+ NULL,
+ };
+ if ( (table < 0) ||
+ (table >= TALER_AUDITORDB_SUPPRESSABLE_TABLES_MAX))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ return tables[table];
+}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] branch master updated (cc5c8a53c -> c96c2f1ac),
gnunet <=