gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] 67/130: fix sharding


From: gnunet
Subject: [taler-exchange] 67/130: fix sharding
Date: Wed, 17 Nov 2021 12:25:15 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

commit 22ce5bff77e922bc0f679e7f450a66dc5f27f148
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Mon Nov 1 18:05:01 2021 +0100

    fix sharding
---
 contrib/gana                                |  2 +-
 src/exchange/taler-exchange-aggregator.c    |  7 +++--
 src/exchangedb/exchange-0001.sql            |  2 +-
 src/exchangedb/plugin_exchangedb_postgres.c | 16 +++++-----
 src/exchangedb/test_exchangedb.c            |  6 ++--
 src/testing/test_auditor_api.c              | 48 +++++++++++++++++------------
 6 files changed, 46 insertions(+), 35 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 8c7d9be4..17555514 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 8c7d9be40ba627348da3e01b91b4f1d3cc78631f
+Subproject commit 17555514bd2866e0d45b23e4a1c198415205c8f2
diff --git a/src/exchange/taler-exchange-aggregator.c 
b/src/exchange/taler-exchange-aggregator.c
index 69c8dc5b..94efe28f 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -319,7 +319,7 @@ parse_wirewatch_config (void)
  * @param amount_with_fee what was the refunded amount with the fee
  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
  */
-static int
+static enum GNUNET_GenericReturnValue
 refund_by_coin_cb (void *cls,
                    const struct TALER_Amount *amount_with_fee)
 {
@@ -768,8 +768,9 @@ run_aggregation (void *cls)
 
   /* Now try to find other deposits to aggregate */
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Found ready deposit for %s, aggregating\n",
-              TALER_B2S (&au_active.merchant_pub));
+              "Found ready deposit for %s, aggregating by target %llu\n",
+              TALER_B2S (&au_active.merchant_pub),
+              (unsigned long long) au_active.wire_target);
   qs = db_plugin->iterate_matching_deposits (db_plugin->cls,
                                              au_active.wire_target,
                                              &au_active.merchant_pub,
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql
index 87ac555b..68eb0733 100644
--- a/src/exchangedb/exchange-0001.sql
+++ b/src/exchangedb/exchange-0001.sql
@@ -386,7 +386,7 @@ CREATE TABLE IF NOT EXISTS deposits
 COMMENT ON TABLE deposits
   IS 'Deposits we have received and for which we need to make (aggregate) wire 
transfers (and manage refunds).';
 COMMENT ON COLUMN deposits.shard
-  IS 'Used for load sharding. Should be set based on h_wire, merchant_pub and 
a service salt. Default of 0 onlyapplies for columns migrated from a previous 
version without sharding support. 64-bit value because we need an *unsigned* 
32-bit value.';
+  IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. 
Default of 0 onlyapplies for columns migrated from a previous version without 
sharding support. 64-bit value because we need an *unsigned* 32-bit value.';
 COMMENT ON COLUMN deposits.wire_target_serial_id
   IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN 
deposits.wire_salt
   IS 'Salt used when hashing the payto://-URI to get the h_wire';
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 199c3d33..66bad461 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -5301,7 +5301,7 @@ postgres_get_ready_deposit (void *cls,
 
   (void) GNUNET_TIME_round_abs (&now);
   GNUNET_assert (start_shard_row < end_shard_row);
-  GNUNET_assert (end_shard_row <= INT64_MAX);
+  GNUNET_assert (end_shard_row <= INT32_MAX);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Finding ready deposits by deadline %s (%llu)\n",
               GNUNET_STRINGS_absolute_time_to_string (now),
@@ -5709,7 +5709,7 @@ postgres_ensure_coin_known (void *cls,
 static uint64_t
 compute_shard (const struct TALER_EXCHANGEDB_Deposit *deposit)
 {
-  uint64_t res;
+  uint32_t res;
 
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CRYPTO_kdf (&res,
@@ -5720,12 +5720,12 @@ compute_shard (const struct TALER_EXCHANGEDB_Deposit 
*deposit)
                                     strlen (deposit->receiver_wire_account),
                                     NULL, 0));
   /* interpret hash result as NBO for platform independence,
-     convert to HBO and map to [0..2^63-1] range */
+     convert to HBO and map to [0..2^31-1] range */
   res = ntohl (res);
-  if (res > INT64_MAX)
-    res += INT64_MIN;
-  GNUNET_assert (res <= INT64_MAX);
-  return res;
+  if (res > INT32_MAX)
+    res += INT32_MIN;
+  GNUNET_assert (res <= INT32_MAX);
+  return (uint64_t) res;
 }
 
 
@@ -5773,7 +5773,7 @@ postgres_insert_deposit (void *cls,
       GNUNET_PQ_query_param_end
     };
 
-    GNUNET_assert (shard <= INT64_MAX);
+    GNUNET_assert (shard <= INT32_MAX);
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Inserting deposit to be executed at %s (%llu/%llu)\n",
                 GNUNET_STRINGS_absolute_time_to_string 
(deposit->wire_deadline),
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 9b8d1a6d..44ae5680 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1864,7 +1864,7 @@ run (void *cls)
   FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_ready_deposit (plugin->cls,
                                      0,
-                                     INT64_MAX,
+                                     INT32_MAX,
                                      &deposit_cb,
                                      &deposit));
   FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
@@ -1885,14 +1885,14 @@ run (void *cls)
   FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
           plugin->get_ready_deposit (plugin->cls,
                                      0,
-                                     INT64_MAX,
+                                     INT32_MAX,
                                      &deposit_cb,
                                      &deposit));
   plugin->rollback (plugin->cls);
   FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
           plugin->get_ready_deposit (plugin->cls,
                                      0,
-                                     INT64_MAX,
+                                     INT32_MAX,
                                      &deposit_cb,
                                      &deposit));
   FAILIF (GNUNET_OK !=
diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c
index 2ea17356..b94866cd 100644
--- a/src/testing/test_auditor_api.c
+++ b/src/testing/test_auditor_api.c
@@ -213,26 +213,35 @@ run (void *cls,
      * happen here, as each deposit operation is run with a
      * fresh merchant public key! NOTE: this comment comes
      * "verbatim" from the old test-suite, and IMO does not explain
-     * a lot!*///
+     * a lot! */
     CMD_EXEC_AGGREGATOR ("run-aggregator"),
 
     /**
      * Check all the transfers took place.
      */
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-499c", ec.exchange_url,
-      "EUR:4.98", bc.exchange_payto, bc.user42_payto),
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-99c1", ec.exchange_url,
-      "EUR:0.98", bc.exchange_payto, bc.user42_payto),
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check_bank_transfer-99c", ec.exchange_url,
-      "EUR:0.08", bc.exchange_payto, bc.user43_payto),
+    TALER_TESTING_cmd_check_bank_transfer (
+      "check_bank_transfer-499c",
+      ec.exchange_url,
+      "EUR:4.98",
+      bc.exchange_payto,
+      bc.user42_payto),
+    TALER_TESTING_cmd_check_bank_transfer (
+      "check_bank_transfer-99c1",
+      ec.exchange_url,
+      "EUR:0.98",
+      bc.exchange_payto,
+      bc.user42_payto),
+    TALER_TESTING_cmd_check_bank_transfer (
+      "check_bank_transfer-99c",
+      ec.exchange_url,
+      "EUR:0.08",
+      bc.exchange_payto,
+      bc.user43_payto),
 
     /* The following transactions got originated within
      * the "massive deposit confirms" batch.  */
-    TALER_TESTING_cmd_check_bank_transfer
-      ("check-massive-transfer-1",
+    TALER_TESTING_cmd_check_bank_transfer (
+      "check-massive-transfer-1",
       ec.exchange_url,
       "EUR:0.98",
       bc.exchange_payto, bc.user43_payto),
@@ -412,7 +421,8 @@ run (void *cls,
      * These commands should close the reserve because the aggregator
      * is given a config file that overrides the reserve expiration
      * time (making it now-ish)
-     */CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve",
+     */
+    CMD_TRANSFER_TO_EXCHANGE ("short-lived-reserve",
                               "EUR:5.01"),
     TALER_TESTING_cmd_exec_wirewatch ("short-lived-aggregation",
                                       CONFIG_FILE_EXPIRE_RESERVE_NOW),
@@ -472,8 +482,8 @@ run (void *cls,
      */
     CMD_TRANSFER_TO_EXCHANGE ("massive-reserve",
                               "EUR:10.10"),
-    TALER_TESTING_cmd_check_bank_admin_transfer
-      ("check-massive-transfer",
+    TALER_TESTING_cmd_check_bank_admin_transfer (
+      "check-massive-transfer",
       "EUR:10.10",
       bc.user42_payto, bc.exchange_payto,
       "massive-reserve"),
@@ -518,8 +528,8 @@ run (void *cls,
                                        "massive-reserve",
                                        "EUR:1",
                                        MHD_HTTP_OK),
-    TALER_TESTING_cmd_deposit
-      ("massive-deposit-1",
+    TALER_TESTING_cmd_deposit (
+      "massive-deposit-1",
       "massive-withdraw-1",
       0,
       bc.user43_payto,
@@ -599,8 +609,8 @@ run (void *cls,
       GNUNET_TIME_UNIT_ZERO,
       "EUR:1",
       MHD_HTTP_OK),
-    TALER_TESTING_cmd_deposit
-      ("massive-deposit-10",
+    TALER_TESTING_cmd_deposit (
+      "massive-deposit-10",
       "massive-withdraw-10",
       0,
       bc.user43_payto,

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