gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: implement taler-auditor-sync sup


From: gnunet
Subject: [taler-exchange] branch master updated: implement taler-auditor-sync support for profit_drains table (#4960)
Date: Sat, 30 Jul 2022 10:29:28 +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 033a5dc9 implement taler-auditor-sync support for profit_drains table 
(#4960)
033a5dc9 is described below

commit 033a5dc93b032a1f1fe6ab1e7d1227b69f0f0c69
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jul 30 10:29:24 2022 +0200

    implement taler-auditor-sync support for profit_drains table (#4960)
---
 src/auditor/taler-auditor-sync.c            |  3 +-
 src/exchangedb/irbt_callbacks.c             | 33 ++++++++++++++++
 src/exchangedb/lrbt_callbacks.c             | 61 +++++++++++++++++++++++++++++
 src/exchangedb/plugin_exchangedb_postgres.c | 49 ++++++++++++++++++++++-
 src/include/taler_exchangedb_plugin.h       | 12 ++++++
 5 files changed, 156 insertions(+), 2 deletions(-)

diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c
index 6a44bc20..9bc59613 100644
--- a/src/auditor/taler-auditor-sync.c
+++ b/src/auditor/taler-auditor-sync.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2020 Taler Systems SA
+  Copyright (C) 2020-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
@@ -125,6 +125,7 @@ static struct Table tables[] = {
   { .rt = TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES},
   { .rt = TALER_EXCHANGEDB_RT_WADS_IN},
   { .rt = TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES},
+  { .rt = TALER_EXCHANGEDB_RT_PROFIT_DRAINS},
   { .end = true }
 };
 
diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c
index 250b167e..bff71cf4 100644
--- a/src/exchangedb/irbt_callbacks.c
+++ b/src/exchangedb/irbt_callbacks.c
@@ -1131,4 +1131,37 @@ irbt_cb_table_wads_in_entries (struct PostgresClosure 
*pg,
 }
 
 
+/**
+ * Function called with profit_drains records to insert into table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ */
+static enum GNUNET_DB_QueryStatus
+irbt_cb_table_profit_drains (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_auto_from_type (
+      &td->details.profit_drains.wtid),
+    GNUNET_PQ_query_param_string (
+      td->details.profit_drains.account_section),
+    GNUNET_PQ_query_param_string (
+      td->details.profit_drains.payto_uri),
+    GNUNET_PQ_query_param_timestamp (
+      &td->details.profit_drains.trigger_date),
+    TALER_PQ_query_param_amount (
+      &td->details.profit_drains.amount),
+    GNUNET_PQ_query_param_auto_from_type (
+      &td->details.profit_drains.master_sig),
+    GNUNET_PQ_query_param_end
+  };
+
+  return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+                                             "insert_into_table_profit_drains",
+                                             params);
+}
+
+
 /* end of irbt_callbacks.c */
diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c
index b8ab49cf..e31b3637 100644
--- a/src/exchangedb/lrbt_callbacks.c
+++ b/src/exchangedb/lrbt_callbacks.c
@@ -2120,4 +2120,65 @@ lrbt_cb_table_wads_in_entries (void *cls,
 }
 
 
+/**
+ * Function called with profit_drains 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_profit_drains (void *cls,
+                             PGresult *result,
+                             unsigned int num_results)
+{
+  struct LookupRecordsByTableContext *ctx = cls;
+  struct PostgresClosure *pg = ctx->pg;
+  struct TALER_EXCHANGEDB_TableData td = {
+    .table = TALER_EXCHANGEDB_RT_PROFIT_DRAINS
+  };
+
+  for (unsigned int i = 0; i<num_results; i++)
+  {
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 (
+        "profit_drain_serial_id",
+        &td.serial),
+      GNUNET_PQ_result_spec_auto_from_type (
+        "wtid",
+        &td.details.profit_drains.wtid),
+      GNUNET_PQ_result_spec_string (
+        "account_section",
+        &td.details.profit_drains.account_section),
+      GNUNET_PQ_result_spec_string (
+        "payto_uri",
+        &td.details.profit_drains.payto_uri),
+      GNUNET_PQ_result_spec_timestamp (
+        "trigger_date",
+        &td.details.profit_drains.trigger_date),
+      TALER_PQ_RESULT_SPEC_AMOUNT (
+        "amount",
+        &td.details.profit_drains.amount),
+      GNUNET_PQ_result_spec_auto_from_type (
+        "master_sig",
+        &td.details.profit_drains.master_sig),
+      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 ca9ae421..88b8eeed 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3149,6 +3149,14 @@ prepare_statements (struct PostgresClosure *pg)
       " ORDER BY wad_in_entry_serial_id DESC"
       " LIMIT 1;",
       0),
+    GNUNET_PQ_make_prepare (
+      "select_serial_by_table_profit_drains",
+      "SELECT"
+      " profit_drain_serial_id AS serial"
+      " FROM profit_drains"
+      " ORDER BY profit_drain_serial_id DESC"
+      " LIMIT 1;",
+      0),
     /* For postgres_lookup_records_by_table */
     GNUNET_PQ_make_prepare (
       "select_above_serial_by_table_denominations",
@@ -3652,6 +3660,21 @@ prepare_statements (struct PostgresClosure *pg)
       " WHERE wad_in_entry_serial_id > $1"
       " ORDER BY wad_in_entry_serial_id ASC;",
       1),
+    GNUNET_PQ_make_prepare (
+      "select_above_serial_by_table_profit_drains",
+      "SELECT"
+      " profit_drain_serial_id"
+      ",wtid"
+      ",account_section"
+      ",payto_uri"
+      ",trigger_date"
+      ",amount_val"
+      ",amount_frac"
+      ",master_sig"
+      " FROM profit_drains"
+      " WHERE profit_drain_serial_id > $1"
+      " ORDER BY profit_drain_serial_id ASC;",
+      1),
     /* For postgres_insert_records_by_table */
     GNUNET_PQ_make_prepare (
       "insert_into_table_denominations",
@@ -4128,7 +4151,21 @@ prepare_statements (struct PostgresClosure *pg)
       ",purse_sig"
       ") VALUES "
       "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);",
-      3),
+      15),
+    GNUNET_PQ_make_prepare (
+      "insert_into_table_profit_drains",
+      "INSERT INTO profit_drains"
+      "(profit_drain_serial_id"
+      ",wtid"
+      ",account_section"
+      ",payto_uri"
+      ",trigger_date"
+      ",amount_val"
+      ",amount_frac"
+      ",master_sig"
+      ") VALUES "
+      "($1, $2, $3, $4, $5, $6, $7, $8);",
+      8),
 
     /* Used in #postgres_begin_shard() */
     GNUNET_PQ_make_prepare (
@@ -14253,6 +14290,9 @@ postgres_lookup_serial_by_table (void *cls,
   case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
     statement = "select_serial_by_table_wads_in_entries";
     break;
+  case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
+    statement = "select_serial_by_table_profit_drains";
+    break;
   default:
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -14474,6 +14514,10 @@ postgres_lookup_records_by_table (void *cls,
     statement = "select_above_serial_by_table_wads_in_entries";
     rh = &lrbt_cb_table_wads_in_entries;
     break;
+  case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
+    statement = "select_above_serial_by_table_profit_drains";
+    rh = &lrbt_cb_table_profit_drains;
+    break;
   default:
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -14641,6 +14685,9 @@ postgres_insert_records_by_table (void *cls,
   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;
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 41ef75a6..4f9a41d1 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -228,6 +228,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable
   TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES,
   TALER_EXCHANGEDB_RT_WADS_IN,
   TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES,
+  TALER_EXCHANGEDB_RT_PROFIT_DRAINS,
 };
 
 
@@ -588,6 +589,17 @@ struct TALER_EXCHANGEDB_TableData
       struct TALER_PurseContractSignatureP purse_sig;
     } wads_in_entries;
 
+    struct
+    {
+      uint64_t profit_drain_serial_id;
+      struct TALER_WireTransferIdentifierRawP wtid;
+      char *account_section;
+      char *payto_uri;
+      struct GNUNET_TIME_Timestamp trigger_date;
+      struct TALER_Amount amount;
+      struct TALER_MasterSignatureP master_sig;
+    } profit_drains;
+
   } 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]