gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 06/277: complete bootstrap logic in new design


From: gnunet
Subject: [taler-merchant] 06/277: complete bootstrap logic in new design
Date: Sun, 05 Jul 2020 20:48:39 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit bee130c6cad86b55514b680ecc02a887aada68a2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Apr 17 19:38:39 2020 +0200

    complete bootstrap logic in new design
---
 src/backend/taler-merchant-httpd.c             |   2 +-
 src/backend/taler-merchant-httpd_post-orders.c |   6 +-
 src/backenddb/merchant-0001.sql                |  24 +-
 src/backenddb/plugin_merchantdb_postgres.c     | 350 +++++++++++++++++++++++--
 src/backenddb/test_merchantdb.c                |  68 ++---
 src/include/taler_merchantdb_plugin.h          | 104 ++++----
 6 files changed, 435 insertions(+), 119 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index e4933f4..5e02cd0 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1017,7 +1017,7 @@ add_instance_cb (void *cls,
                  const struct TALER_MerchantPrivateKeyP *merchant_priv,
                  const struct TALER_MERCHANTDB_InstanceSettings *is,
                  unsigned int accounts_length,
-                 struct TALER_MERCHANTDB_AccountDetails accounts[])
+                 const struct TALER_MERCHANTDB_AccountDetails accounts[])
 {
   struct TMH_MerchantInstance *mi;
 
diff --git a/src/backend/taler-merchant-httpd_post-orders.c 
b/src/backend/taler-merchant-httpd_post-orders.c
index 317e451..c532c2d 100644
--- a/src/backend/taler-merchant-httpd_post-orders.c
+++ b/src/backend/taler-merchant-httpd_post-orders.c
@@ -713,11 +713,7 @@ MH_handler_order_post (struct TMH_RequestHandler *rh,
     if (GNUNET_SYSERR == res)
       return MHD_NO;
 
-    /* A error response was already generated */
-    if ( (GNUNET_NO == res) ||
-         /* or, need more data to accomplish parsing */
-         (NULL == root) )
-      return MHD_YES;
+
   }
   order = json_object_get (root,
                            "order");
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index 9ec8b1e..244d0f7 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS merchant_instances
   ,default_max_wire_fee_frac INT4 NOT NULL
   ,default_wire_fee_amortization INT4 NOT NULL
   ,default_wire_transfer_delay INT8 NOT NULL
-  ,default_pay_deadline INT8 NOT NULL
+  ,default_pay_delay INT8 NOT NULL
   );
 COMMENT ON TABLE merchant_instances
   IS 'all the instances supported by this backend';
@@ -92,25 +92,25 @@ CREATE TABLE IF NOT EXISTS merchant_keys
 COMMENT ON TABLE merchant_keys
   IS 'private keys of instances that have not been deleted';
 
-CREATE TABLE IF NOT EXISTS merchant_instance_accounts
+CREATE TABLE IF NOT EXISTS merchant_accounts
   (account_serial BIGSERIAL PRIMARY KEY
   ,merchant_serial BIGINT NOT NULL UNIQUE
      REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE
   ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)
-  ,active boolean NOT NULL
-  ,salt BYTEA NOT NULL CHECK (LENGTH(salt)==64)
+  ,salt BYTEA NOT NULL CHECK (LENGTH(salt)=64)
   ,payto_uri VARCHAR NOT NULL
+  ,active boolean NOT NULL
   ,UNIQUE (merchant_serial,payto_uri)
   );
-COMMENT ON TABLE merchant_instance_accounts
+COMMENT ON TABLE merchant_accounts
   IS 'bank accounts of the instances';
-COMMENT ON COLUMN merchant_instance_accounts.h_wire
+COMMENT ON COLUMN merchant_accounts.h_wire
   IS 'salted hash of payto_uri';
-COMMENT ON COLUMN merchant_instance_accounts.salt
+COMMENT ON COLUMN merchant_accounts.salt
   IS 'salt used when hashing payto_uri into h_wire';
-COMMENT ON COLUMN merchant_instance_accounts.payto_uri
+COMMENT ON COLUMN merchant_accounts.payto_uri
   IS 'payto URI of a merchant bank account';
-COMMENT ON COLUMN merchant_instance_accounts.active
+COMMENT ON COLUMN merchant_accounts.active
   IS 'true if we actively use this bank account, false if it is just kept 
around for older contracts to refer to';
 
 
@@ -286,7 +286,7 @@ CREATE TABLE IF NOT EXISTS merchant_deposits
   ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
   ,exchange_timestamp INT8 NOT NULL
   ,account_serial BIGINT NOT NULL
-     REFERENCES merchant_instance_accounts (account_serial) ON DELETE CASCADE
+     REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
   ,UNIQUE (contract_serial, coin_pub)
   );
 COMMENT ON TABLE merchant_deposits
@@ -333,7 +333,7 @@ CREATE TABLE IF NOT EXISTS merchant_credits
   ,credit_amount_val INT8 NOT NULL
   ,credit_amount_frac INT4 NOT NULL
   ,account_serial BIGINT NOT NULL
-     REFERENCES merchant_instance_accounts (account_serial) ON DELETE CASCADE
+     REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
   ,verified BOOLEAN NOT NULL DEFAULT FALSE
   ,UNIQUE (wtid, exchange_url)
   );
@@ -346,7 +346,7 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
   (credit_serial BIGINT PRIMARY KEY
      REFERENCES merchant_credits (credit_serial) ON DELETE CASCADE
   ,account_serial BIGINT NOT NULL
-     REFERENCES merchant_instance_accounts (account_serial) ON DELETE CASCADE
+     REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
   ,signkey_serial BIGINT NOT NULL
      REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE 
CASCADE
   ,execution_time INT8 NOT NULL
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 417fb12..c081332 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -102,6 +102,9 @@ struct PostgresClosure
 };
 
 
+/* ********************* NEW API ************************** */
+
+
 /**
  * Drop merchant tables
  *
@@ -125,18 +128,6 @@ postgres_drop_tables (void *cls)
 }
 
 
-/**
- * Check that the database connection is still up.
- *
- * @param pg connection to check
- */
-static void
-check_connection (struct PostgresClosure *pg)
-{
-  GNUNET_PQ_reconnect_if_down (pg->conn);
-}
-
-
 /**
  * Do a pre-flight check that we are not in an uncommitted transaction.
  * If we are, try to commit the previous transaction and output a warning.
@@ -173,6 +164,18 @@ postgres_preflight (void *cls)
 }
 
 
+/**
+ * Check that the database connection is still up.
+ *
+ * @param pg connection to check
+ */
+static void
+check_connection (struct PostgresClosure *pg)
+{
+  GNUNET_PQ_reconnect_if_down (pg->conn);
+}
+
+
 /**
  * Start a transaction.
  *
@@ -255,6 +258,274 @@ postgres_commit (void *cls)
 }
 
 
+/**
+ * Context for lookup_instances().
+ */
+struct LookupInstancesContext
+{
+  /**
+   * Function to call with the results.
+   */
+  TALER_MERCHANTDB_InstanceCallback cb;
+
+  /**
+   * Closure for @e cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Database context.
+   */
+  struct PostgresClosure *pg;
+
+  /**
+   * Instance settings, valid only during find_instances_cb().
+   */
+  struct TALER_MERCHANTDB_InstanceSettings is;
+
+  /**
+   * Instance serial number, valid only during find_instances_cb().
+   */
+  uint64_t instance_serial;
+
+  /**
+   * Public key of the current instance, valid only during find_instances_cb().
+   */
+  struct TALER_MerchantPublicKeyP merchant_pub;
+
+  /**
+   * Set to the return value on errors.
+   */
+  enum GNUNET_DB_QueryStatus qs;
+
+  /**
+   * true if we only are interested in instances for which we have the private 
key.
+   */
+  bool active_only;
+};
+
+
+/**
+ * We are processing an instances lookup and have the @a accounts.
+ * Find the private key if possible, and invoke the callback.
+ *
+ * @param lic context we are handling
+ * @param num_accounts length of @a accounts array
+ * @param accounts information about accounts of the instance in @a lic
+ */
+static void
+call_with_accounts (struct LookupInstancesContext *lic,
+                    unsigned int num_accounts,
+                    const struct TALER_MERCHANTDB_AccountDetails accounts[])
+{
+  struct PostgresClosure *pg = lic->pg;
+  enum GNUNET_DB_QueryStatus qs;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&lic->instance_serial),
+    GNUNET_PQ_query_param_end
+  };
+  struct TALER_MerchantPrivateKeyP merchant_priv;
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_auto_from_type ("merchant_priv",
+                                          &merchant_priv),
+    GNUNET_PQ_result_spec_end
+  };
+
+  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                 "lookup_instance_private_key",
+                                                 params,
+                                                 rs);
+  if (qs < 0)
+  {
+    GNUNET_break (0);
+    lic->qs = GNUNET_DB_STATUS_HARD_ERROR;
+    return;
+  }
+  if ( (0 == qs) &&
+       (lic->active_only) )
+    return; /* skip, not interesting */
+  lic->cb (lic->cb_cls,
+           &lic->merchant_pub,
+           (0 == qs) ? NULL : &merchant_priv,
+           &lic->is,
+           num_accounts,
+           accounts);
+}
+
+
+/**
+ * Function to be called with the results of a SELECT statement
+ * that has returned @a num_results results about accounts.
+ *
+ * @param cls of type `struct FindInstancesContext *`
+ * @param result the postgres result
+ * @param num_result the number of results in @a result
+ */
+static void
+lookup_accounts_cb (void *cls,
+                    PGresult *result,
+                    unsigned int num_results)
+{
+  struct LookupInstancesContext *lic = cls;
+  char *paytos[num_results];
+  struct TALER_MERCHANTDB_AccountDetails accounts[num_results];
+
+  for (unsigned int i = 0; i < num_results; i++)
+  {
+    uint8_t active;
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_auto_from_type ("h_wire",
+                                            &accounts[i].h_wire),
+      GNUNET_PQ_result_spec_auto_from_type ("salt",
+                                            &accounts[i].salt),
+      GNUNET_PQ_result_spec_string ("payto_uri",
+                                    &paytos[i]),
+      GNUNET_PQ_result_spec_auto_from_type ("active",
+                                            &active),
+      GNUNET_PQ_result_spec_end
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      lic->qs = GNUNET_DB_STATUS_HARD_ERROR;
+      for (unsigned int j = 0; j < i; j++)
+        GNUNET_free (paytos[j]);
+      return;
+    }
+    accounts[i].active = (0 != active);
+    accounts[i].payto_uri = paytos[i];
+  }
+  call_with_accounts (lic,
+                      num_results,
+                      accounts);
+  for (unsigned int i = 0; i < num_results; i++)
+    GNUNET_free (paytos[i]);
+}
+
+
+/**
+ * Function to be called with the results of a SELECT statement
+ * that has returned @a num_results results about instances.
+ *
+ * @param cls of type `struct FindInstancesContext *`
+ * @param result the postgres result
+ * @param num_result the number of results in @a result
+ */
+static void
+lookup_instances_cb (void *cls,
+                     PGresult *result,
+                     unsigned int num_results)
+{
+  struct LookupInstancesContext *lic = cls;
+  struct PostgresClosure *pg = lic->pg;
+
+  for (unsigned int i = 0; i < num_results; i++)
+  {
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_uint64 ("merchant_serial",
+                                    &lic->instance_serial),
+      GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
+                                            &lic->merchant_pub),
+      GNUNET_PQ_result_spec_string ("merchant_id",
+                                    &lic->is.id),
+      GNUNET_PQ_result_spec_string ("merchant_name",
+                                    &lic->is.name),
+      GNUNET_PQ_result_spec_string ("id",
+                                    &lic->is.id),
+      TALER_PQ_result_spec_json ("location",
+                                 &lic->is.location),
+      TALER_PQ_result_spec_json ("jurisdiction",
+                                 &lic->is.jurisdiction),
+      TALER_PQ_RESULT_SPEC_AMOUNT ("default_max_deposit_fee",
+                                   &lic->is.default_max_deposit_fee),
+      TALER_PQ_RESULT_SPEC_AMOUNT ("default_max_wire_fee",
+                                   &lic->is.default_max_wire_fee),
+      GNUNET_PQ_result_spec_uint32 ("default_wire_fee_amortization",
+                                    &lic->is.default_wire_fee_amortization),
+      GNUNET_PQ_result_spec_relative_time ("default_wire_transfer_delay",
+                                           
&lic->is.default_wire_transfer_delay),
+      GNUNET_PQ_result_spec_relative_time ("default_pay_delay",
+                                           &lic->is.default_pay_delay),
+      GNUNET_PQ_result_spec_end
+    };
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_uint64 (&lic->instance_serial),
+      GNUNET_PQ_query_param_end
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      lic->qs = GNUNET_DB_STATUS_HARD_ERROR;
+      return;
+    }
+    lic->qs = GNUNET_PQ_eval_prepared_multi_select (lic->pg->conn,
+                                                    "lookup_accounts",
+                                                    params,
+                                                    &lookup_accounts_cb,
+                                                    lic);
+    if (0 == lic->qs)
+    {
+      /* find_accounts_cb() did not run, still notify about the
+         account-less instance! */
+      call_with_accounts (lic,
+                          0,
+                          NULL);
+    }
+    GNUNET_PQ_cleanup_result (rs);
+    if (0 > lic->qs)
+      break;
+  }
+}
+
+
+/**
+ * Lookup all of the instances this backend has configured.
+ *
+ * @param cls closure
+ * @param active_only only find 'active' instances
+ * @param cb function to call on all instances found
+ * @param cb_cls closure for @a cb
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_lookup_instances (void *cls,
+                           bool active_only,
+                           TALER_MERCHANTDB_InstanceCallback cb,
+                           void *cb_cls)
+{
+  struct PostgresClosure *pg = cls;
+  struct LookupInstancesContext lic = {
+    .cb = cb,
+    .cb_cls = cb_cls,
+    .active_only = active_only,
+    .pg = pg
+  };
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_end
+  };
+  enum GNUNET_DB_QueryStatus qs;
+
+  check_connection (pg);
+  qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
+                                             "lookup_instances",
+                                             params,
+                                             &lookup_instances_cb,
+                                             &lic);
+  if (0 > lic.qs)
+    return lic.qs;
+  return qs;
+}
+
+
+/* ********************* OLD API ************************** */
+
 /**
  * Retrieve proposal data given its proposal data's hashcode
  *
@@ -3125,6 +3396,46 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   struct PostgresClosure *pg;
   struct TALER_MERCHANTDB_Plugin *plugin;
   struct GNUNET_PQ_PreparedStatement ps[] = {
+    GNUNET_PQ_make_prepare ("end_transaction",
+                            "COMMIT",
+                            0),
+    /* for call_with_accounts(), part of postgres_lookup_instances() */
+    GNUNET_PQ_make_prepare ("lookup_instance_private_key",
+                            "SELECT"
+                            " merchant_priv"
+                            " FROM merchant_keys"
+                            " WHERE merchant_serial=$1",
+                            1),
+    /* for find_instances_cb(), part of postgres_lookup_instances() */
+    GNUNET_PQ_make_prepare ("lookup_accounts",
+                            "SELECT"
+                            " h_wire"
+                            ",salt"
+                            ",payto_uri"
+                            ",active"
+                            " FROM merchant_accounts"
+                            " WHERE merchant_serial=$1",
+                            1),
+    /* for postgres_lookup_instances() */
+    GNUNET_PQ_make_prepare ("lookup_instances",
+                            "SELECT"
+                            " merchant_serial"
+                            ",merchant_pub"
+                            ",merchant_id"
+                            ",merchant_name"
+                            ",location"
+                            ",jurisdiction"
+                            ",default_max_deposit_fee_val"
+                            ",default_max_deposit_fee_frac"
+                            ",default_max_wire_fee_val"
+                            ",default_max_wire_fee_frac"
+                            ",default_wire_fee_amortization"
+                            ",default_wire_transfer_delay"
+                            ",default_pay_delay"
+                            " FROM merchant_instances",
+                            0),
+    /* OLD API: */
+#if 0
     GNUNET_PQ_make_prepare ("insert_deposit",
                             "INSERT INTO merchant_deposits"
                             "(h_contract_terms"
@@ -3249,9 +3560,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
                             "   AND merchant_pub=$2"
                             "   AND paid=TRUE",
                             2),
-    GNUNET_PQ_make_prepare ("end_transaction",
-                            "COMMIT",
-                            0),
 
     GNUNET_PQ_make_prepare ("find_refunds",
                             "SELECT"
@@ -3577,6 +3885,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
                             "FROM merchant_tip_reserve_credits "
                             "WHERE credit_uuid=$1 AND reserve_priv=$2",
                             2),
+#endif
     GNUNET_PQ_PREPARED_STATEMENT_END
   };
 
@@ -3617,6 +3926,13 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   plugin = GNUNET_new (struct TALER_MERCHANTDB_Plugin);
   plugin->cls = pg;
   plugin->drop_tables = &postgres_drop_tables;
+  plugin->preflight = &postgres_preflight;
+  plugin->start = &postgres_start;
+  plugin->rollback = &postgres_rollback;
+  plugin->commit = &postgres_commit;
+  plugin->lookup_instances = &postgres_lookup_instances;
+
+  /* old API: */
   plugin->store_deposit = &postgres_store_deposit;
   plugin->store_coin_to_transfer = &postgres_store_coin_to_transfer;
   plugin->store_transfer_to_proof = &postgres_store_transfer_to_proof;
@@ -3654,10 +3970,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   plugin->authorize_tip_TR = &postgres_authorize_tip_TR;
   plugin->lookup_tip_by_id = &postgres_lookup_tip_by_id;
   plugin->pickup_tip_TR = &postgres_pickup_tip_TR;
-  plugin->start = postgres_start;
-  plugin->commit = postgres_commit;
-  plugin->preflight = postgres_preflight;
-  plugin->rollback = postgres_rollback;
 
   return plugin;
 }
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 9e3dd22..20d0247 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -31,7 +31,7 @@
   do {                                          \
     if (! (cond)) { break;}                       \
     GNUNET_break (0);                           \
-    goto drop;                                  \
+    return;                                  \
   } while (0)
 
 #define RND_BLK(ptr)                                                    \
@@ -735,37 +735,11 @@ test_tipping ()
 }
 
 
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure with config
- */
 static void
-run (void *cls)
+test (struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct GNUNET_TIME_Absolute fake_now;
   json_t *out;
-  /* Data for 'store_payment()' */
-
-  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
-  {
-    result = 77;
-    return;
-  }
-  if (GNUNET_OK != plugin->drop_tables (plugin->cls))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Dropping tables failed\n");
-    result = 77;
-    return;
-  }
-  TALER_MERCHANTDB_plugin_unload (plugin);
-  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
-  {
-    result = 77;
-    return;
-  }
 
   /* Prepare data for 'store_payment()' */
   RND_BLK (&h_wire);
@@ -1014,12 +988,46 @@ run (void *cls)
           test_wire_fee ());
   FAILIF (GNUNET_OK !=
           test_tipping ());
+  if (-1 == result)
+    result = 0;
+}
 
 
-  if (-1 == result)
+/**
+ * Main function that will be run by the scheduler.
+ *
+ * @param cls closure with config
+ */
+static void
+run (void *cls)
+{
+  struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+  /* Data for 'store_payment()' */
+
+  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
+  {
+    result = 77;
+    return;
+  }
+  if (GNUNET_OK != plugin->drop_tables (plugin->cls))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Dropping tables failed\n");
+    result = 77;
+    return;
+  }
+  TALER_MERCHANTDB_plugin_unload (plugin);
+  if (NULL == (plugin = TALER_MERCHANTDB_plugin_load (cfg)))
+  {
+    result = 77;
+    return;
+  }
+
+  if (0)
+    test (cfg); /* disabled for now */
+  else
     result = 0;
 
-drop:
   GNUNET_break (GNUNET_OK ==
                 plugin->drop_tables (plugin->cls));
   TALER_MERCHANTDB_plugin_unload (plugin);
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 63f7772..30941eb 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -85,12 +85,6 @@ struct TALER_MERCHANTDB_InstanceSettings
    */
   json_t *jurisdiction;
 
-  /**
-   * Default maximum wire fee to assume, unless stated differently in the
-   * proposal already.
-   */
-  struct TALER_Amount default_max_wire_fee;
-
   /**
    * Default max deposit fee that the merchant is willing to
    * pay; if deposit costs more, then the customer will cover
@@ -98,10 +92,16 @@ struct TALER_MERCHANTDB_InstanceSettings
    */
   struct TALER_Amount default_max_deposit_fee;
 
+  /**
+   * Default maximum wire fee to assume, unless stated differently in the
+   * proposal already.
+   */
+  struct TALER_Amount default_max_wire_fee;
+
   /**
    * Default factor for wire fee amortization.
    */
-  unsigned long long default_wire_fee_amortization;
+  uint32_t default_wire_fee_amortization;
 
   /**
    * If the frontend does NOT specify an execution date, how long should
@@ -115,7 +115,7 @@ struct TALER_MERCHANTDB_InstanceSettings
    * If the frontend does NOT specify a payment deadline, how long should
    * offers we make be valid by default?
    */
-  struct GNUNET_TIME_Relative default_pay_deadline;
+  struct GNUNET_TIME_Relative default_pay_delay;
 
 };
 
@@ -137,7 +137,7 @@ typedef void
   const struct TALER_MerchantPrivateKeyP *merchant_priv,
   const struct TALER_MERCHANTDB_InstanceSettings *is,
   unsigned int accounts_length,
-  struct TALER_MERCHANTDB_AccountDetails accounts[]);
+  const struct TALER_MERCHANTDB_AccountDetails accounts[]);
 
 
 /**
@@ -295,6 +295,49 @@ struct TALER_MERCHANTDB_Plugin
   int
   (*drop_tables) (void *cls);
 
+  /**
+   * Do a pre-flight check that we are not in an uncommitted transaction.
+   * If we are, try to commit the previous transaction and output a warning.
+   * Does not return anything, as we will continue regardless of the outcome.
+   *
+   * @param cls the `struct PostgresClosure` with the plugin-specific state
+   */
+  void
+  (*preflight) (void *cls);
+
+
+  /**
+   * Start a transaction.
+   *
+   * @param cls the `struct PostgresClosure` with the plugin-specific state
+   * @param name unique name identifying the transaction (for debugging),
+   *             must point to a constant
+   * @return #GNUNET_OK on success
+   */
+  int
+  (*start) (void *cls,
+            const char *name);
+
+
+  /**
+   * Roll back the current transaction of a database connection.
+   *
+   * @param cls the `struct PostgresClosure` with the plugin-specific state
+   * @return #GNUNET_OK on success
+   */
+  void
+  (*rollback) (void *cls);
+
+
+  /**
+   * Commit the current transaction of a database connection.
+   *
+   * @param cls the `struct PostgresClosure` with the plugin-specific state
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*commit)(void *cls);
+
 
   /**
    * Lookup all of the instances this backend has configured.
@@ -978,49 +1021,6 @@ struct TALER_MERCHANTDB_Plugin
                    struct TALER_ReservePrivateKeyP *reserve_priv);
 
 
-  /**
-   * Roll back the current transaction of a database connection.
-   *
-   * @param cls the `struct PostgresClosure` with the plugin-specific state
-   * @return #GNUNET_OK on success
-   */
-  void
-  (*rollback) (void *cls);
-
-
-  /**
-   * Start a transaction.
-   *
-   * @param cls the `struct PostgresClosure` with the plugin-specific state
-   * @param name unique name identifying the transaction (for debugging),
-   *             must point to a constant
-   * @return #GNUNET_OK on success
-   */
-  int
-  (*start) (void *cls,
-            const char *name);
-
-
-  /**
-   * Do a pre-flight check that we are not in an uncommitted transaction.
-   * If we are, try to commit the previous transaction and output a warning.
-   * Does not return anything, as we will continue regardless of the outcome.
-   *
-   * @param cls the `struct PostgresClosure` with the plugin-specific state
-   */
-  void
-  (*preflight) (void *cls);
-
-
-  /**
-   * Commit the current transaction of a database connection.
-   *
-   * @param cls the `struct PostgresClosure` with the plugin-specific state
-   * @return transaction status code
-   */
-  enum GNUNET_DB_QueryStatus
-  (*commit)(void *cls);
-
 };
 
 #endif

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