gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: -more plugin refactoring


From: gnunet
Subject: [taler-exchange] branch master updated: -more plugin refactoring
Date: Sat, 08 Oct 2022 18:07:12 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new f2a3a28d -more plugin refactoring
f2a3a28d is described below

commit f2a3a28d46e8b61ff4c68c639156be7b00dd6f51
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sat Oct 8 18:07:05 2022 +0200

    -more plugin refactoring
---
 src/exchangedb/Makefile.am                         |   1 +
 ...bt_callbacks.c => pg_insert_records_by_table.c} | 151 +++++++++++++++++++-
 src/exchangedb/pg_insert_records_by_table.h        |  43 ++++++
 src/exchangedb/plugin_exchangedb_postgres.c        | 158 +--------------------
 4 files changed, 195 insertions(+), 158 deletions(-)

diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 1fc89d1b..d46b6456 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -71,6 +71,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
   plugin_exchangedb_postgres.c pg_helper.h \
   pg_do_reserve_open.c pg_do_reserve_open.h \
   pg_insert_close_request.c pg_insert_close_request.h \
+  pg_insert_records_by_table.c pg_insert_records_by_table.h \
   pg_insert_reserve_open_deposit.c pg_insert_reserve_open_deposit.h \
   pg_iterate_kyc_reference.c pg_iterate_kyc_reference.h \
   pg_iterate_reserve_close_info.c pg_iterate_reserve_close_info.h \
diff --git a/src/exchangedb/irbt_callbacks.c 
b/src/exchangedb/pg_insert_records_by_table.c
similarity index 93%
rename from src/exchangedb/irbt_callbacks.c
rename to src/exchangedb/pg_insert_records_by_table.c
index 82812781..2d41390e 100644
--- a/src/exchangedb/irbt_callbacks.c
+++ b/src/exchangedb/pg_insert_records_by_table.c
@@ -18,14 +18,30 @@
      SPDX-License-Identifier: AGPL3.0-or-later
  */
 /**
- * @file exchangedb/irbt_callbacks.c
- * @brief callbacks used by postgres_insert_records_by_table, to be
- *        inlined into the plugin
+ * @file exchangedb/insert_records_by_table.c
+ * @brief insert_records_by_table implementation
  * @author Christian Grothoff
  */
+#include "platform.h"
+#include "taler_error_codes.h"
+#include "taler_dbevents.h"
+#include "taler_pq_lib.h"
+#include "pg_insert_records_by_table.h"
 #include "pg_helper.h"
 
 
+/**
+ * Signature of helper functions of #postgres_insert_records_by_table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ * @return transaction status code
+ */
+typedef enum GNUNET_DB_QueryStatus
+(*InsertRecordCallback)(struct PostgresClosure *pg,
+                        const struct TALER_EXCHANGEDB_TableData *td);
+
+
 /**
  * Function called with denominations records to insert into table.
  *
@@ -1755,4 +1771,133 @@ irbt_cb_table_profit_drains (struct PostgresClosure *pg,
 }
 
 
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_records_by_table (void *cls,
+                                const struct TALER_EXCHANGEDB_TableData *td)
+{
+  struct PostgresClosure *pg = cls;
+  InsertRecordCallback rh;
+
+  switch (td->table)
+  {
+  case TALER_EXCHANGEDB_RT_DENOMINATIONS:
+    rh = &irbt_cb_table_denominations;
+    break;
+  case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
+    rh = &irbt_cb_table_denomination_revocations;
+    break;
+  case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
+    rh = &irbt_cb_table_wire_targets;
+    break;
+  case TALER_EXCHANGEDB_RT_RESERVES:
+    rh = &irbt_cb_table_reserves;
+    break;
+  case TALER_EXCHANGEDB_RT_RESERVES_IN:
+    rh = &irbt_cb_table_reserves_in;
+    break;
+  case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
+    rh = &irbt_cb_table_reserves_close;
+    break;
+  case TALER_EXCHANGEDB_RT_RESERVES_OUT:
+    rh = &irbt_cb_table_reserves_out;
+    break;
+  case TALER_EXCHANGEDB_RT_AUDITORS:
+    rh = &irbt_cb_table_auditors;
+    break;
+  case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
+    rh = &irbt_cb_table_auditor_denom_sigs;
+    break;
+  case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
+    rh = &irbt_cb_table_exchange_sign_keys;
+    break;
+  case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
+    rh = &irbt_cb_table_signkey_revocations;
+    break;
+  case TALER_EXCHANGEDB_RT_KNOWN_COINS:
+    rh = &irbt_cb_table_known_coins;
+    break;
+  case TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS:
+    rh = &irbt_cb_table_refresh_commitments;
+    break;
+  case TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS:
+    rh = &irbt_cb_table_refresh_revealed_coins;
+    break;
+  case TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS:
+    rh = &irbt_cb_table_refresh_transfer_keys;
+    break;
+  case TALER_EXCHANGEDB_RT_DEPOSITS:
+    rh = &irbt_cb_table_deposits;
+    break;
+  case TALER_EXCHANGEDB_RT_REFUNDS:
+    rh = &irbt_cb_table_refunds;
+    break;
+  case TALER_EXCHANGEDB_RT_WIRE_OUT:
+    rh = &irbt_cb_table_wire_out;
+    break;
+  case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
+    rh = &irbt_cb_table_aggregation_tracking;
+    break;
+  case TALER_EXCHANGEDB_RT_WIRE_FEE:
+    rh = &irbt_cb_table_wire_fee;
+    break;
+  case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
+    rh = &irbt_cb_table_global_fee;
+    break;
+  case TALER_EXCHANGEDB_RT_RECOUP:
+    rh = &irbt_cb_table_recoup;
+    break;
+  case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
+    rh = &irbt_cb_table_recoup_refresh;
+    break;
+  case TALER_EXCHANGEDB_RT_EXTENSIONS:
+    rh = &irbt_cb_table_extensions;
+    break;
+  case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
+    rh = &irbt_cb_table_extension_details;
+    break;
+  case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
+    rh = &irbt_cb_table_purse_requests;
+    break;
+  case TALER_EXCHANGEDB_RT_PURSE_REFUNDS:
+    rh = &irbt_cb_table_purse_refunds;
+    break;
+  case TALER_EXCHANGEDB_RT_PURSE_MERGES:
+    rh = &irbt_cb_table_purse_merges;
+    break;
+  case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
+    rh = &irbt_cb_table_purse_deposits;
+    break;
+  case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
+    rh = &irbt_cb_table_account_mergers;
+    break;
+  case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
+    rh = &irbt_cb_table_history_requests;
+    break;
+  case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
+    rh = &irbt_cb_table_close_requests;
+    break;
+  case TALER_EXCHANGEDB_RT_WADS_OUT:
+    rh = &irbt_cb_table_wads_out;
+    break;
+  case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
+    rh = &irbt_cb_table_wads_out_entries;
+    break;
+  case TALER_EXCHANGEDB_RT_WADS_IN:
+    rh = &irbt_cb_table_wads_in;
+    break;
+  case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
+    rh = &irbt_cb_table_wads_in_entries;
+    break;
+  case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
+    rh = &irbt_cb_table_profit_drains;
+    break;
+  default:
+    GNUNET_break (0);
+    return GNUNET_DB_STATUS_HARD_ERROR;
+  }
+  return rh (pg,
+             td);
+}
+
+
 /* end of irbt_callbacks.c */
diff --git a/src/exchangedb/pg_insert_records_by_table.h 
b/src/exchangedb/pg_insert_records_by_table.h
new file mode 100644
index 00000000..d9817e0e
--- /dev/null
+++ b/src/exchangedb/pg_insert_records_by_table.h
@@ -0,0 +1,43 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 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
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file pg_insert_records_by_table.h
+ * @brief implementation of the insert_records_by_table function
+ * @author Christian Grothoff
+ */
+#ifndef PG_INSERT_RECORDS_BY_TABLE_H
+#define PG_INSERT_RECORDS_BY_TABLE_H
+
+#include "taler_util.h"
+#include "taler_json_lib.h"
+#include "taler_exchangedb_plugin.h"
+
+
+/**
+ * Insert record set into @a table.  Used in exchange-auditor database
+ * replication.
+ *
+ * @param cls closure
+ * @param td table data to insert
+ * @return transaction status code, #GNUNET_DB_STATUS_HARD_ERROR if
+ *         @e table in @a tr is not supported
+ */
+enum GNUNET_DB_QueryStatus
+TEH_PG_insert_records_by_table (void *cls,
+                                const struct TALER_EXCHANGEDB_TableData *td);
+
+
+#endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index a98551d0..b828bb28 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -31,6 +31,7 @@
 #include "taler_exchangedb_plugin.h"
 #include "pg_helper.h"
 #include "pg_insert_close_request.h"
+#include "pg_insert_records_by_table.h"
 #include "pg_insert_reserve_open_deposit.h"
 #include "pg_iterate_kyc_reference.h"
 #include "pg_iterate_reserve_close_info.h"
@@ -14035,159 +14036,6 @@ postgres_lookup_records_by_table (void *cls,
 }
 
 
-/**
- * Signature of helper functions of #postgres_insert_records_by_table.
- *
- * @param pg plugin context
- * @param td record to insert
- * @return transaction status code
- */
-typedef enum GNUNET_DB_QueryStatus
-(*InsertRecordCallback)(struct PostgresClosure *pg,
-                        const struct TALER_EXCHANGEDB_TableData *td);
-
-
-#include "irbt_callbacks.c"
-
-
-/**
- * Insert record set into @a table.  Used in exchange-auditor database
- * replication.
- *
- * @param cls closure
- * @param td table data to insert
- * @return transaction status code, #GNUNET_DB_STATUS_HARD_ERROR if
- *         @e table in @a tr is not supported
- */
-static enum GNUNET_DB_QueryStatus
-postgres_insert_records_by_table (void *cls,
-                                  const struct TALER_EXCHANGEDB_TableData *td)
-{
-  struct PostgresClosure *pg = cls;
-  InsertRecordCallback rh;
-
-  switch (td->table)
-  {
-  case TALER_EXCHANGEDB_RT_DENOMINATIONS:
-    rh = &irbt_cb_table_denominations;
-    break;
-  case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
-    rh = &irbt_cb_table_denomination_revocations;
-    break;
-  case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
-    rh = &irbt_cb_table_wire_targets;
-    break;
-  case TALER_EXCHANGEDB_RT_RESERVES:
-    rh = &irbt_cb_table_reserves;
-    break;
-  case TALER_EXCHANGEDB_RT_RESERVES_IN:
-    rh = &irbt_cb_table_reserves_in;
-    break;
-  case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
-    rh = &irbt_cb_table_reserves_close;
-    break;
-  case TALER_EXCHANGEDB_RT_RESERVES_OUT:
-    rh = &irbt_cb_table_reserves_out;
-    break;
-  case TALER_EXCHANGEDB_RT_AUDITORS:
-    rh = &irbt_cb_table_auditors;
-    break;
-  case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
-    rh = &irbt_cb_table_auditor_denom_sigs;
-    break;
-  case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
-    rh = &irbt_cb_table_exchange_sign_keys;
-    break;
-  case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
-    rh = &irbt_cb_table_signkey_revocations;
-    break;
-  case TALER_EXCHANGEDB_RT_KNOWN_COINS:
-    rh = &irbt_cb_table_known_coins;
-    break;
-  case TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS:
-    rh = &irbt_cb_table_refresh_commitments;
-    break;
-  case TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS:
-    rh = &irbt_cb_table_refresh_revealed_coins;
-    break;
-  case TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS:
-    rh = &irbt_cb_table_refresh_transfer_keys;
-    break;
-  case TALER_EXCHANGEDB_RT_DEPOSITS:
-    rh = &irbt_cb_table_deposits;
-    break;
-  case TALER_EXCHANGEDB_RT_REFUNDS:
-    rh = &irbt_cb_table_refunds;
-    break;
-  case TALER_EXCHANGEDB_RT_WIRE_OUT:
-    rh = &irbt_cb_table_wire_out;
-    break;
-  case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
-    rh = &irbt_cb_table_aggregation_tracking;
-    break;
-  case TALER_EXCHANGEDB_RT_WIRE_FEE:
-    rh = &irbt_cb_table_wire_fee;
-    break;
-  case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
-    rh = &irbt_cb_table_global_fee;
-    break;
-  case TALER_EXCHANGEDB_RT_RECOUP:
-    rh = &irbt_cb_table_recoup;
-    break;
-  case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
-    rh = &irbt_cb_table_recoup_refresh;
-    break;
-  case TALER_EXCHANGEDB_RT_EXTENSIONS:
-    rh = &irbt_cb_table_extensions;
-    break;
-  case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
-    rh = &irbt_cb_table_extension_details;
-    break;
-  case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
-    rh = &irbt_cb_table_purse_requests;
-    break;
-  case TALER_EXCHANGEDB_RT_PURSE_REFUNDS:
-    rh = &irbt_cb_table_purse_refunds;
-    break;
-  case TALER_EXCHANGEDB_RT_PURSE_MERGES:
-    rh = &irbt_cb_table_purse_merges;
-    break;
-  case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
-    rh = &irbt_cb_table_purse_deposits;
-    break;
-  case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
-    rh = &irbt_cb_table_account_mergers;
-    break;
-  case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
-    rh = &irbt_cb_table_history_requests;
-    break;
-  case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
-    rh = &irbt_cb_table_close_requests;
-    break;
-  case TALER_EXCHANGEDB_RT_WADS_OUT:
-    rh = &irbt_cb_table_wads_out;
-    break;
-  case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
-    rh = &irbt_cb_table_wads_out_entries;
-    break;
-  case TALER_EXCHANGEDB_RT_WADS_IN:
-    rh = &irbt_cb_table_wads_in;
-    break;
-  case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
-    rh = &irbt_cb_table_wads_in_entries;
-    break;
-  case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
-    rh = &irbt_cb_table_profit_drains;
-    break;
-  default:
-    GNUNET_break (0);
-    return GNUNET_DB_STATUS_HARD_ERROR;
-  }
-  return rh (pg,
-             td);
-}
-
-
 /**
  * Function called to grab a work shard on an operation @a op. Runs in its
  * own transaction.
@@ -16737,8 +16585,6 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &postgres_lookup_serial_by_table;
   plugin->lookup_records_by_table
     = &postgres_lookup_records_by_table;
-  plugin->insert_records_by_table
-    = &postgres_insert_records_by_table;
   plugin->begin_shard
     = &postgres_begin_shard;
   plugin->abort_shard
@@ -16816,6 +16662,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
   plugin->select_merge_amounts_for_kyc_check
     = &postgres_select_merge_amounts_for_kyc_check;
   /* NEW style, sort alphabetically! */
+  plugin->insert_records_by_table
+    = &TEH_PG_insert_records_by_table;
   plugin->insert_reserve_open_deposit
     = &TEH_PG_insert_reserve_open_deposit;
   plugin->insert_close_request

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]