gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: sync tables "extensions" and "ex


From: gnunet
Subject: [taler-exchange] branch master updated: sync tables "extensions" and "extension_details" with auditor
Date: Sat, 05 Mar 2022 13:39:28 +0100

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

oec pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 8a906bf9 sync tables "extensions" and "extension_details" with auditor
8a906bf9 is described below

commit 8a906bf96c9c418dbd58727284eb5cfdd6fdff24
Author: Özgür Kesim <oec-taler@kesim.org>
AuthorDate: Sat Mar 5 13:36:50 2022 +0100

    sync tables "extensions" and "extension_details" with auditor
---
 src/auditor/taler-auditor-sync.c            |  2 +
 src/exchangedb/irbt_callbacks.c             | 51 ++++++++++++++++
 src/exchangedb/lrbt_callbacks.c             | 95 +++++++++++++++++++++++++++++
 src/exchangedb/plugin_exchangedb_postgres.c | 53 ++++++++++++++++
 src/include/taler_exchangedb_plugin.h       | 15 ++++-
 5 files changed, 215 insertions(+), 1 deletion(-)

diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c
index 4b9595c6..91b3b081 100644
--- a/src/auditor/taler-auditor-sync.c
+++ b/src/auditor/taler-auditor-sync.c
@@ -111,6 +111,8 @@ static struct Table tables[] = {
   { .rt = TALER_EXCHANGEDB_RT_WIRE_FEE},
   { .rt = TALER_EXCHANGEDB_RT_RECOUP},
   { .rt = TALER_EXCHANGEDB_RT_RECOUP_REFRESH },
+  { .rt = TALER_EXCHANGEDB_RT_EXTENSIONS},
+  { .rt = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS },
   { .end = true }
 };
 
diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c
index 012f8df2..deab3cfc 100644
--- a/src/exchangedb/irbt_callbacks.c
+++ b/src/exchangedb/irbt_callbacks.c
@@ -702,4 +702,55 @@ irbt_cb_table_recoup_refresh (struct PostgresClosure *pg,
 }
 
 
+/**
+ * Function called with extensions records to insert into table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ */
+static enum GNUNET_DB_QueryStatus
+irbt_cb_table_extensions (struct PostgresClosure *pg,
+                          const struct TALER_EXCHANGEDB_TableData *td)
+{
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&td->serial),
+    GNUNET_PQ_query_param_string (td->details.extensions.name),
+    NULL == td->details.extensions.config ?
+    GNUNET_PQ_query_param_null () :
+    GNUNET_PQ_query_param_string (td->details.extensions.config),
+    GNUNET_PQ_query_param_end
+  };
+
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_into_table_extensions",
+                                             params);
+}
+
+
+/**
+ * Function called with extension_details records to insert into table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ */
+static enum GNUNET_DB_QueryStatus
+irbt_cb_table_extension_details (struct PostgresClosure *pg,
+                                 const struct TALER_EXCHANGEDB_TableData *td)
+{
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&td->serial),
+    NULL ==
+    td->details.extension_details.extension_options ?
+    GNUNET_PQ_query_param_null () :
+    GNUNET_PQ_query_param_string (
+      td->details.extension_details.extension_options),
+    GNUNET_PQ_query_param_end
+  };
+
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             
"insert_into_table_extension_details",
+                                             params);
+}
+
+
 /* end of irbt_callbacks.c */
diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c
index f7b0e28d..7f1d2fdb 100644
--- a/src/exchangedb/lrbt_callbacks.c
+++ b/src/exchangedb/lrbt_callbacks.c
@@ -1306,4 +1306,99 @@ lrbt_cb_table_recoup_refresh (void *cls,
 }
 
 
+/**
+ * Function called with extensions table entries.
+ *
+ * @param cls closure
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+lrbt_cb_table_extensions (void *cls,
+                          PGresult *result,
+                          unsigned int num_results)
+{
+  struct LookupRecordsByTableContext *ctx = cls;
+  struct TALER_EXCHANGEDB_TableData td = {
+    .table = TALER_EXCHANGEDB_RT_EXTENSIONS
+  };
+  bool no_config = false;
+
+  for (unsigned int i = 0; i<num_results; i++)
+  {
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 ("extension_id",
+                                    &td.serial),
+      GNUNET_PQ_result_spec_string ("name",
+                                    &td.details.extensions.name),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_string ("config",
+                                      &td.details.extensions.config),
+        &no_config),
+      GNUNET_PQ_result_spec_end
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      ctx->error = true;
+      return;
+    }
+    ctx->cb (ctx->cb_cls,
+             &td);
+    GNUNET_PQ_cleanup_result (rs);
+  }
+}
+
+
+/**
+ * Function called with extension_details table entries.
+ *
+ * @param cls closure
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+lrbt_cb_table_extension_details (void *cls,
+                                 PGresult *result,
+                                 unsigned int num_results)
+{
+  struct LookupRecordsByTableContext *ctx = cls;
+  struct TALER_EXCHANGEDB_TableData td = {
+    .table = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS
+  };
+  bool no_config = false;
+
+  for (unsigned int i = 0; i<num_results; i++)
+  {
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 ("extension_details_serial_id",
+                                    &td.serial),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_string ("extension_options",
+                                      &td.details.extension_details.
+                                      extension_options),
+        &no_config),
+      GNUNET_PQ_result_spec_end
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      ctx->error = true;
+      return;
+    }
+    ctx->cb (ctx->cb_cls,
+             &td);
+    GNUNET_PQ_cleanup_result (rs);
+  }
+}
+
+
 /* end of lrbt_callbacks.c */
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 754654e3..9a3229f4 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -2123,6 +2123,22 @@ prepare_statements (struct PostgresClosure *pg)
       " ORDER BY recoup_refresh_uuid DESC"
       " LIMIT 1;",
       0),
+    GNUNET_PQ_make_prepare (
+      "select_serial_by_table_extensions",
+      "SELECT"
+      " extension_id AS serial"
+      " FROM extensions"
+      " ORDER BY extension_id DESC"
+      " LIMIT 1;",
+      0),
+    GNUNET_PQ_make_prepare (
+      "select_serial_by_table_extension_details",
+      "SELECT"
+      " extension_details_serial_id AS serial"
+      " FROM extension_details"
+      " ORDER BY extension_details_serial_id DESC"
+      " LIMIT 1;",
+      0),
     /* For postgres_lookup_records_by_table */
     GNUNET_PQ_make_prepare (
       "select_above_serial_by_table_denominations",
@@ -2727,6 +2743,23 @@ prepare_statements (struct PostgresClosure *pg)
       ") VALUES "
       "($1, $2, $3, $4, $5, $6, $7, $8);",
       8),
+    GNUNET_PQ_make_prepare (
+      "insert_into_table_extensions",
+      "INSERT INTO extensions"
+      "(extension_id"
+      ",name"
+      ",config"
+      ") VALUES "
+      "($1, $2, $3);",
+      3),
+    GNUNET_PQ_make_prepare (
+      "insert_into_table_extension_details",
+      "INSERT INTO extension_details"
+      "(extension_details_serial_id"
+      ",extension_options"
+      ") VALUES "
+      "($1, $2);",
+      2),
 
     /* Used in #postgres_begin_shard() */
     GNUNET_PQ_make_prepare (
@@ -10807,6 +10840,12 @@ postgres_lookup_serial_by_table (void *cls,
   case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
     statement = "select_serial_by_table_recoup_refresh";
     break;
+  case TALER_EXCHANGEDB_RT_EXTENSIONS:
+    statement = "select_serial_by_table_extensions";
+    break;
+  case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
+    statement = "select_serial_by_table_extension_details";
+    break;
   default:
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -10972,6 +11011,14 @@ postgres_lookup_records_by_table (void *cls,
     statement = "select_above_serial_by_table_recoup_refresh";
     rh = &lrbt_cb_table_recoup_refresh;
     break;
+  case TALER_EXCHANGEDB_RT_EXTENSIONS:
+    statement = "select_above_serial_by_table_extensions";
+    rh = &lrbt_cb_table_extensions;
+    break;
+  case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
+    statement = "select_above_serial_by_table_extension_details";
+    rh = &lrbt_cb_table_extension_details;
+    break;
   default:
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -11097,6 +11144,12 @@ postgres_insert_records_by_table (void *cls,
   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;
   default:
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index c8953b94..878cfe2f 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -169,7 +169,9 @@ enum TALER_EXCHANGEDB_ReplicatedTable
   TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING,
   TALER_EXCHANGEDB_RT_WIRE_FEE,
   TALER_EXCHANGEDB_RT_RECOUP,
-  TALER_EXCHANGEDB_RT_RECOUP_REFRESH
+  TALER_EXCHANGEDB_RT_RECOUP_REFRESH,
+  TALER_EXCHANGEDB_RT_EXTENSIONS,
+  TALER_EXCHANGEDB_RT_EXTENSION_DETAILS,
 };
 
 
@@ -407,6 +409,17 @@ struct TALER_EXCHANGEDB_TableData
       uint64_t rrc_serial;
     } recoup_refresh;
 
+    struct
+    {
+      char *name;
+      char *config;
+    } extensions;
+
+    struct
+    {
+      char *extension_options;
+    } extension_details;
+
   } details;
 
 };

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