gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: more work on DB plugin for manag


From: gnunet
Subject: [taler-exchange] branch master updated: more work on DB plugin for managemetn API
Date: Sun, 29 Nov 2020 17:27:57 +0100

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 855e7829 more work on DB plugin for managemetn API
855e7829 is described below

commit 855e7829d764aa178020ce4423449dcb5a8536ce
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 29 17:27:53 2020 +0100

    more work on DB plugin for managemetn API
---
 src/exchangedb/exchange-0002.sql            |   4 +-
 src/exchangedb/plugin_exchangedb_postgres.c | 161 ++++++++++++++++++++++++++--
 src/include/taler_exchangedb_plugin.h       |   4 +-
 3 files changed, 153 insertions(+), 16 deletions(-)

diff --git a/src/exchangedb/exchange-0002.sql b/src/exchangedb/exchange-0002.sql
index 2162c45e..f90097da 100644
--- a/src/exchangedb/exchange-0002.sql
+++ b/src/exchangedb/exchange-0002.sql
@@ -98,6 +98,7 @@ CREATE TABLE IF NOT EXISTS auditor_denom_sigs
   (auditor_pub BYTEA NOT NULL REFERENCES auditors (auditor_pub) ON DELETE 
CASCADE
   ,denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON 
DELETE CASCADE
   ,auditor_sig BYTEA PRIMARY KEY CHECK (LENGTH(auditor_sig)=64)
+  ,PRIMARY KEY (denom_pub_hash, auditor_pub)
   );
 COMMENT ON TABLE auditor_denom_sigs
   IS 'Table with auditor signatures on exchange denomination keys.';
@@ -107,9 +108,6 @@ COMMENT ON COLUMN auditor_denom_sigs.denom_pub_hash
   IS 'Denomination the signature is for.';
 COMMENT ON COLUMN auditor_denom_sigs.auditor_sig
   IS 'Signature of the auditor, of purpose 
TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS.';
-CREATE INDEX IF NOT EXISTS auditor_denom_sigs_denom_hash_index
-  ON auditor_denom_sigs
-  (denom_pub_hash);
 
 
 CREATE TABLE IF NOT EXISTS exchange_sign_keys
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 843d3901..f7ddac5e 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1412,7 +1412,6 @@ postgres_get_session (void *cls)
                               " FROM auditors"
                               " WHERE auditor_pub=$1;",
                               1),
-
       /* Used in #postgres_lookup_wire_timestamp() */
       GNUNET_PQ_make_prepare ("lookup_wire_timestamp",
                               "SELECT"
@@ -1459,6 +1458,63 @@ postgres_get_session (void *cls)
                               " ,last_change=$3"
                               " WHERE payto_uri=$1",
                               3),
+      /* used in #postgres_insert_signkey_revocation() */
+      GNUNET_PQ_make_prepare ("insert_signkey_revocation",
+                              "INSERT INTO signkey_revocations "
+                              "(exchange_pub"
+                              ",master_sig"
+                              ") VALUES "
+                              "($1, $2);",
+                              2),
+      /* used in #postgres_lookup_future_denomination_key() */
+      GNUNET_PQ_make_prepare ("lookup_future_denomination_key",
+                              "SELECT"
+                              " valid_from"
+                              ",expire_withdraw"
+                              ",expire_deposit"
+                              ",expire_legal"
+                              ",coin_val"
+                              ",coin_frac"
+                              ",fee_withdraw_val"
+                              ",fee_withdraw_frac"
+                              ",fee_deposit_val"
+                              ",fee_deposit_frac"
+                              ",fee_refresh_val"
+                              ",fee_refresh_frac"
+                              ",fee_refund_val"
+                              ",fee_refund_frac"
+                              " FROM future_denominations"
+                              " WHERE denom_pub_hash=$1;",
+                              1),
+      /* used in #postgres_lookup_denomination_key() */
+      GNUNET_PQ_make_prepare ("lookup_denomination_key",
+                              "SELECT"
+                              " valid_from"
+                              ",expire_withdraw"
+                              ",expire_deposit"
+                              ",expire_legal"
+                              ",coin_val"
+                              ",coin_frac"
+                              ",fee_withdraw_val"
+                              ",fee_withdraw_frac"
+                              ",fee_deposit_val"
+                              ",fee_deposit_frac"
+                              ",fee_refresh_val"
+                              ",fee_refresh_frac"
+                              ",fee_refund_val"
+                              ",fee_refund_frac"
+                              " FROM denominations"
+                              " WHERE denom_pub_hash=$1;",
+                              1),
+      /* used in #postgres_insert_auditor_denom_sig() */
+      GNUNET_PQ_make_prepare ("insert_auditor_denom_sig",
+                              "INSERT INTO auditor_denom_sigs "
+                              "(auditor_pub"
+                              ",denom_pub_hash"
+                              ",auditor_sig"
+                              ") VALUES "
+                              "($1, $2, $3);",
+                              3),
       /* used in #postgres_commit */
       GNUNET_PQ_make_prepare ("do_commit",
                               "COMMIT",
@@ -7629,8 +7685,16 @@ postgres_insert_signkey_revocation (
   const struct TALER_ExchangePublicKeyP *exchange_pub,
   const struct TALER_MasterSignatureP *master_sig)
 {
-  GNUNET_break (0); // FIXME: not implemented
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (exchange_pub),
+    GNUNET_PQ_query_param_auto_from_type (master_sig),
+    GNUNET_PQ_query_param_end
+  };
+
+  (void) cls;
+  return GNUNET_PQ_eval_prepared_non_select (session->conn,
+                                             "insert_signkey_revocation",
+                                             params);
 }
 
 
@@ -7648,10 +7712,39 @@ postgres_lookup_future_denomination_key (
   void *cls,
   struct TALER_EXCHANGEDB_Session *session,
   const struct GNUNET_HashCode *h_denom_pub,
-  const struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
+  struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
 {
-  GNUNET_break (0); // FIXME: not implemented
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    TALER_PQ_result_spec_absolute_time ("valid_from",
+                                        &meta->start),
+    TALER_PQ_result_spec_absolute_time ("expire_withdraw",
+                                        &meta->expire_withdraw),
+    TALER_PQ_result_spec_absolute_time ("expire_deposit",
+                                        &meta->expire_deposit),
+    TALER_PQ_result_spec_absolute_time ("expire_legal",
+                                        &meta->expire_legal),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
+                                 &meta->value),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
+                                 &meta->fee_withdraw),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
+                                 &meta->fee_deposit),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
+                                 &meta->fee_refresh),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
+                                 &meta->fee_refund),
+    GNUNET_PQ_result_spec_end
+  };
+
+  return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+                                                   
"lookup_future_denomination_key",
+                                                   params,
+                                                   rs);
 }
 
 
@@ -7669,10 +7762,39 @@ postgres_lookup_denomination_key (
   void *cls,
   struct TALER_EXCHANGEDB_Session *session,
   const struct GNUNET_HashCode *h_denom_pub,
-  const struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
+  struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta)
 {
-  GNUNET_break (0); // FIXME: not implemented
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    TALER_PQ_result_spec_absolute_time ("valid_from",
+                                        &meta->start),
+    TALER_PQ_result_spec_absolute_time ("expire_withdraw",
+                                        &meta->expire_withdraw),
+    TALER_PQ_result_spec_absolute_time ("expire_deposit",
+                                        &meta->expire_deposit),
+    TALER_PQ_result_spec_absolute_time ("expire_legal",
+                                        &meta->expire_legal),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
+                                 &meta->value),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
+                                 &meta->fee_withdraw),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
+                                 &meta->fee_deposit),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
+                                 &meta->fee_refresh),
+    TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
+                                 &meta->fee_refund),
+    GNUNET_PQ_result_spec_end
+  };
+
+  return GNUNET_PQ_eval_prepared_singleton_select (session->conn,
+                                                   "lookup_denomination_key",
+                                                   params,
+                                                   rs);
 }
 
 
@@ -7719,8 +7841,17 @@ postgres_insert_auditor_denom_sig (
   const struct TALER_AuditorPublicKeyP *auditor_pub,
   const struct TALER_AuditorSignatureP *auditor_sig)
 {
-  GNUNET_break (0); // FIXME: not implemented
-  return GNUNET_DB_STATUS_HARD_ERROR;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
+    GNUNET_PQ_query_param_auto_from_type (auditor_pub),
+    GNUNET_PQ_query_param_auto_from_type (auditor_sig),
+    GNUNET_PQ_query_param_end
+  };
+
+  (void) cls;
+  return GNUNET_PQ_eval_prepared_non_select (session->conn,
+                                             "insert_auditor_denom_sig",
+                                             params);
 }
 
 
@@ -7926,6 +8057,14 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &postgres_insert_wire;
   plugin->update_wire
     = &postgres_update_wire;
+  plugin->insert_signkey_revocation
+    = &postgres_insert_signkey_revocation;
+  plugin->lookup_future_denomination_key
+    = &postgres_lookup_future_denomination_key;
+  plugin->lookup_denomination_key
+    = &postgres_lookup_denomination_key;
+  plugin->insert_auditor_denom_sig
+    = &postgres_insert_auditor_denom_sig;
   return plugin;
 }
 
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 0f5e693d..27ba0b49 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -3120,7 +3120,7 @@ struct TALER_EXCHANGEDB_Plugin
     void *cls,
     struct TALER_EXCHANGEDB_Session *session,
     const struct GNUNET_HashCode *h_denom_pub,
-    const struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta);
+    struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta);
 
 
   /**
@@ -3137,7 +3137,7 @@ struct TALER_EXCHANGEDB_Plugin
     void *cls,
     struct TALER_EXCHANGEDB_Session *session,
     const struct GNUNET_HashCode *h_denom_pub,
-    const struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta);
+    struct TALER_EXCHANGEDB_DenominationKeyMetaData *meta);
 
 
   /**

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