gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (c0ef3f27 -> 2c3d548b)


From: gnunet
Subject: [taler-exchange] branch master updated (c0ef3f27 -> 2c3d548b)
Date: Fri, 08 Mar 2024 11:18:24 +0100

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

grothoff pushed a change to branch master
in repository exchange.

    from c0ef3f27 updating last from prebuilt
     new a50e6990 add taler-exchange-dbinit -a option
     new 2c3d548b merge

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:
 contrib/gana                                       |  2 +-
 contrib/wallet-core                                |  2 +-
 doc/prebuilt                                       |  2 +-
 src/exchange-tools/taler-exchange-dbinit.c         | 20 ++++++++++++-
 src/exchangedb/Makefile.am                         |  2 ++
 .../auditor-triggers-0001.sql}                     | 23 ++++++++++++--
 src/exchangedb/drop.sql                            | 10 ++++++-
 src/exchangedb/pg_create_tables.c                  |  1 -
 ..._drop_tables.c => pg_inject_auditor_triggers.c} | 35 +++++++++++-----------
 .../{pg_gc.h => pg_inject_auditor_triggers.h}      | 16 +++++-----
 src/exchangedb/plugin_exchangedb_postgres.c        |  3 ++
 src/include/taler_exchangedb_plugin.h              | 28 ++++++++++++++---
 12 files changed, 106 insertions(+), 38 deletions(-)
 copy src/{auditordb/procedures.sql.in => exchangedb/auditor-triggers-0001.sql} 
(58%)
 copy src/exchangedb/{pg_drop_tables.c => pg_inject_auditor_triggers.c} (64%)
 copy src/exchangedb/{pg_gc.h => pg_inject_auditor_triggers.h} (72%)

diff --git a/contrib/gana b/contrib/gana
index 2b581279..4728c9e6 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 2b581279ae67a1068b07a8c010ac1ab7b85e18df
+Subproject commit 4728c9e60ce121f439b3db30cc08f06ff0beff71
diff --git a/contrib/wallet-core b/contrib/wallet-core
index 35212ac5..64dea5e9 160000
--- a/contrib/wallet-core
+++ b/contrib/wallet-core
@@ -1 +1 @@
-Subproject commit 35212ac57bfe5625fcf574b0fd2d9baf395dc4c0
+Subproject commit 64dea5e94086d8f79d1af7e5b7ee045d72d02495
diff --git a/doc/prebuilt b/doc/prebuilt
index af8c69df..60ccf04b 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit af8c69dfe397ff4bed7abca98ed8f3b2ed70541b
+Subproject commit 60ccf04bb3579c249a899c4ae88e120acda13c83
diff --git a/src/exchange-tools/taler-exchange-dbinit.c 
b/src/exchange-tools/taler-exchange-dbinit.c
index d2cd22c1..41ff2ab2 100644
--- a/src/exchange-tools/taler-exchange-dbinit.c
+++ b/src/exchange-tools/taler-exchange-dbinit.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2022 Taler Systems SA
+  Copyright (C) 2014-2024 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
@@ -29,6 +29,11 @@
  */
 static int global_ret;
 
+/**
+ * -a option: inject auditor triggers
+ */
+static int inject_auditor;
+
 /**
  * -r option: do full DB reset
  */
@@ -133,6 +138,15 @@ run (void *cls,
       }
     }
   }
+  if (inject_auditor)
+  {
+    if (GNUNET_SYSERR == plugin->inject_auditor_triggers (plugin->cls))
+    {
+      fprintf (stderr,
+               "Injecting auditor triggers failed!\n");
+      global_ret = EXIT_FAILURE;
+    }
+  }
   TALER_EXCHANGEDB_plugin_unload (plugin);
   plugin = NULL;
 }
@@ -151,6 +165,10 @@ main (int argc,
       char *const *argv)
 {
   const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    GNUNET_GETOPT_option_flag ('a',
+                               "inject-auditor",
+                               "inject auditor triggers",
+                               &inject_auditor),
     GNUNET_GETOPT_option_flag ('g',
                                "gc",
                                "garbage collect database",
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 2959f07e..af6e2166 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -23,6 +23,7 @@ sqlinputs = \
 sql_DATA = \
   benchmark-0001.sql \
   versioning.sql \
+  auditor-triggers-0001.sql \
   exchange-0001.sql \
   exchange-0002.sql \
   drop.sql \
@@ -98,6 +99,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
   pg_select_contract_by_purse.h pg_select_contract_by_purse.c \
   pg_insert_drain_profit.h pg_insert_drain_profit.c \
   pg_insert_kyc_failure.h pg_insert_kyc_failure.c \
+  pg_inject_auditor_triggers.h pg_inject_auditor_triggers.c \
   pg_create_tables.h pg_create_tables.c \
   pg_event_listen.h pg_event_listen.c \
   pg_event_listen_cancel.h pg_event_listen_cancel.c \
diff --git a/src/auditordb/procedures.sql.in 
b/src/exchangedb/auditor-triggers-0001.sql
similarity index 58%
copy from src/auditordb/procedures.sql.in
copy to src/exchangedb/auditor-triggers-0001.sql
index 0c83bdb5..4e2ea66c 100644
--- a/src/auditordb/procedures.sql.in
+++ b/src/exchangedb/auditor-triggers-0001.sql
@@ -14,11 +14,28 @@
 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 --
 
+-- Everything in one big transaction
 BEGIN;
 
-SET search_path TO auditor;
+SELECT _v.register_patch('auditor-triggers-0001');
+
+SET search_path TO exchange;
+
+CREATE OR REPLACE FUNCTION auditor_new_deposits_trigger()
+    RETURNS trigger
+    LANGUAGE plpgsql
+AS $$
+BEGIN
+    NOTIFY XFIXME;
+    RETURN NEW;
+END $$;
+COMMENT ON FUNCTION auditor_new_deposits_trigger()
+    IS 'Call XXX on new entry';
+
+CREATE TRIGGER auditor_notify_helper_insert_deposits
+    AFTER INSERT
+    ON exchange.batch_deposits
+EXECUTE PROCEDURE auditor_new_deposits_trigger();
 
-#include "auditor_do_get_auditor_progress.sql"
-#include "auditor_do_get_balance.sql"
 
 COMMIT;
diff --git a/src/exchangedb/drop.sql b/src/exchangedb/drop.sql
index ff383d74..fa7609bf 100644
--- a/src/exchangedb/drop.sql
+++ b/src/exchangedb/drop.sql
@@ -17,10 +17,18 @@
 -- Everything in one big transaction
 BEGIN;
 
-
+-- TODO: consider use exchange-* in the future!
 SELECT _v.unregister_patch('exchange-0001');
 SELECT _v.unregister_patch('exchange-0002');
 
+WITH xpatches AS (
+  SELECT patch_name
+  FROM _v.patches
+  WHERE patch_name='auditor-triggers-0001' -- TODO: use auditor-triggers-* in 
the future!
+)
+  SELECT _v.unregister_patch(xpatches.patch_name)
+  FROM xpatches;
+
 DROP SCHEMA exchange CASCADE;
 
 COMMIT;
diff --git a/src/exchangedb/pg_create_tables.c 
b/src/exchangedb/pg_create_tables.c
index 1d5728d8..f6a06190 100644
--- a/src/exchangedb/pg_create_tables.c
+++ b/src/exchangedb/pg_create_tables.c
@@ -52,7 +52,6 @@ TEH_PG_create_tables (void *cls,
     GNUNET_PQ_EXECUTE_STATEMENT_END
   };
 
-
   conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
                                      "exchangedb-postgres",
                                      "exchange-",
diff --git a/src/exchangedb/pg_drop_tables.c 
b/src/exchangedb/pg_inject_auditor_triggers.c
similarity index 64%
copy from src/exchangedb/pg_drop_tables.c
copy to src/exchangedb/pg_inject_auditor_triggers.c
index 55857018..562a1a22 100644
--- a/src/exchangedb/pg_drop_tables.c
+++ b/src/exchangedb/pg_inject_auditor_triggers.c
@@ -14,45 +14,44 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_drop_tables.c
- * @brief Implementation of the drop_tables function for Postgres
+ * @file exchangedb/pg_inject_auditor_triggers.c
+ * @brief Implementation of the inject_auditor_triggers function for Postgres
  * @author Christian Grothoff
  */
 #include "platform.h"
 #include "taler_error_codes.h"
 #include "taler_dbevents.h"
 #include "taler_pq_lib.h"
-#include "pg_drop_tables.h"
+#include "pg_gc.h"
 #include "pg_helper.h"
 
 
 /**
- * Drop all Taler tables.  This should only be used by testcases.
+ * Function called to inject auditor triggers into the
+ * database, triggering the real-time auditor upon
+ * relevant INSERTs.
  *
- * @param cls the `struct PostgresClosure` with the plugin-specific state
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
+ * @param cls closure
+ * @return #GNUNET_OK on success,
+ *         #GNUNET_SYSERR on DB errors
  */
 enum GNUNET_GenericReturnValue
-TEH_PG_drop_tables (void *cls)
+TEH_PG_inject_auditor_triggers (void *cls)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_Context *conn;
-  enum GNUNET_GenericReturnValue ret;
+  struct GNUNET_PQ_ExecuteStatement es[] = {
+    GNUNET_PQ_make_try_execute ("SET search_path TO exchange;"),
+    GNUNET_PQ_EXECUTE_STATEMENT_END
+  };
 
-  if (NULL != pg->conn)
-  {
-    GNUNET_PQ_disconnect (pg->conn);
-    pg->conn = NULL;
-  }
   conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
                                      "exchangedb-postgres",
-                                     NULL,
-                                     NULL,
+                                     "auditor-triggers-",
+                                     es,
                                      NULL);
   if (NULL == conn)
     return GNUNET_SYSERR;
-  ret = GNUNET_PQ_exec_sql (conn,
-                            "drop");
   GNUNET_PQ_disconnect (conn);
-  return ret;
+  return GNUNET_OK;
 }
diff --git a/src/exchangedb/pg_gc.h 
b/src/exchangedb/pg_inject_auditor_triggers.h
similarity index 72%
copy from src/exchangedb/pg_gc.h
copy to src/exchangedb/pg_inject_auditor_triggers.h
index 80358148..2dfa9468 100644
--- a/src/exchangedb/pg_gc.h
+++ b/src/exchangedb/pg_inject_auditor_triggers.h
@@ -14,26 +14,28 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_gc.h
- * @brief implementation of the gc function for Postgres
+ * @file exchangedb/pg_inject_auditor_triggers.h
+ * @brief implementation of the inject_auditor_triggers function for Postgres
  * @author Christian Grothoff
  */
-#ifndef PG_GC_H
-#define PG_GC_H
+#ifndef PG_INJECT_AUDITOR_TRIGGERS_H
+#define PG_INJECT_AUDITOR_TRIGGERS_H
 
 #include "taler_util.h"
 #include "taler_json_lib.h"
 #include "taler_exchangedb_plugin.h"
 
 /**
- * Function called to perform "garbage collection" on the
- * database, expiring records we no longer require.
+ * Function called to inject auditor triggers into the
+ * database, triggering the real-time auditor upon
+ * relevant INSERTs.
  *
  * @param cls closure
  * @return #GNUNET_OK on success,
  *         #GNUNET_SYSERR on DB errors
  */
 enum GNUNET_GenericReturnValue
-TEH_PG_gc (void *cls);
+TEH_PG_inject_auditor_triggers (void *cls);
+
 
 #endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 2c51a5bf..108b5521 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -161,6 +161,7 @@
 #include "pg_start_deferred_wire_out.h"
 #include "pg_store_wire_transfer_out.h"
 #include "pg_gc.h"
+#include "pg_inject_auditor_triggers.h"
 #include "pg_select_coin_deposits_above_serial_id.h"
 #include "pg_select_purse_decisions_above_serial_id.h"
 #include "pg_select_purse_deposits_by_purse.h"
@@ -790,6 +791,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
 
   plugin->batch_ensure_coin_known
     = &TEH_PG_batch_ensure_coin_known;
+  plugin->inject_auditor_triggers
+    = &TEH_PG_inject_auditor_triggers;
 
   return plugin;
 }
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index c7bffbd8..5cd63f2b 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -34,16 +34,24 @@
  */
 enum TALER_EXCHANGEDB_AgeCommitmentHash_Conflict
 {
-  /* Value OK, no conflict */
+  /**
+   * Value OK, no conflict
+   */
   TALER_AgeCommitmentHash_NoConflict    = 0,
 
-  /* Given hash had a value, but NULL (or zero) was expected */
+  /**
+   * Given hash had a value, but NULL (or zero) was expected
+   */
   TALER_AgeCommitmentHash_NullExpected  = 1,
 
-  /* Given hash was NULL, but value was expected */
+  /**
+   * Given hash was NULL, but value was expected
+   */
   TALER_AgeCommitmentHash_ValueExpected = 2,
 
-  /* Given hash differs from value in the known coin */
+  /**
+   * Given hash differs from value in the known coin
+   */
   TALER_AgeCommitmentHash_ValueDiffers  = 3,
 };
 
@@ -7206,6 +7214,18 @@ struct TALER_EXCHANGEDB_Plugin
     const char *provider_account_id,
     const char *provider_legitimization_id);
 
+  /**
+   * Function called to inject auditor triggers into the
+   * database, triggering the real-time auditor upon
+   * relevant INSERTs.
+   *
+   * @param cls closure
+   * @return #GNUNET_OK on success,
+   *         #GNUNET_SYSERR on DB errors
+   */
+  enum GNUNET_GenericReturnValue
+  (*inject_auditor_triggers)(void *cls);
+
 };
 
 #endif /* _TALER_EXCHANGE_DB_H */

-- 
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]