gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (fdf095c6 -> ad839043)


From: gnunet
Subject: [taler-exchange] branch master updated (fdf095c6 -> ad839043)
Date: Sat, 19 Jun 2021 14:58:04 +0200

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

grothoff pushed a change to branch master
in repository exchange.

    from fdf095c6 initial version of taler-bank-benchmark
     new 8c0492be misc fakebank fixes
     new ad839043 add config file for bank benchmarking

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/bank-lib/fakebank.c                            | 108 ++++++++++++++-------
 .../{benchmark.conf => bank-benchmark.conf}        |   7 +-
 src/benchmark/benchmark.conf                       |   5 +
 src/benchmark/taler-bank-benchmark.c               |  89 ++++++++++-------
 src/include/taler_fakebank_lib.h                   |  45 ---------
 5 files changed, 138 insertions(+), 116 deletions(-)
 copy src/benchmark/{benchmark.conf => bank-benchmark.conf} (94%)

diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 978253b5..06470210 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -576,14 +576,17 @@ clean_transaction (struct TALER_FAKEBANK_Handle *h,
                                 t);
   GNUNET_assert (0 ==
                  pthread_mutex_unlock (&ca->lock));
-  GNUNET_assert (0 ==
-                 pthread_mutex_lock (&h->uuid_map_lock));
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONTAINER_multihashmap_remove (h->uuid_map,
-                                                       &t->request_uid,
-                                                       t));
-  GNUNET_assert (0 ==
-                 pthread_mutex_unlock (&h->uuid_map_lock));
+  if (T_DEBIT == t->type)
+  {
+    GNUNET_assert (0 ==
+                   pthread_mutex_lock (&h->uuid_map_lock));
+    GNUNET_assert (GNUNET_OK ==
+                   GNUNET_CONTAINER_multihashmap_remove (h->uuid_map,
+                                                         &t->request_uid,
+                                                         t));
+    GNUNET_assert (0 ==
+                   pthread_mutex_unlock (&h->uuid_map_lock));
+  }
   t->debit_account = NULL;
   t->credit_account = NULL;
 }
@@ -671,8 +674,22 @@ post_transaction (struct Transaction *t)
 }
 
 
-int
-TALER_FAKEBANK_make_transfer (
+/**
+ * Tell the fakebank to create another wire transfer *from* an exchange.
+ *
+ * @param h fake bank handle
+ * @param debit_account account to debit
+ * @param credit_account account to credit
+ * @param amount amount to transfer
+ * @param subject wire transfer subject to use
+ * @param exchange_base_url exchange URL
+ * @param request_uid unique number to make the request unique, or NULL to 
create one
+ * @param[out] ret_row_id pointer to store the row ID of this transaction
+ * @return #GNUNET_YES if the transfer was successful,
+ *         #GNUNET_SYSERR if the request_uid was reused for a different 
transfer
+ */
+static int
+make_transfer (
   struct TALER_FAKEBANK_Handle *h,
   const char *debit_account,
   const char *credit_account,
@@ -782,13 +799,27 @@ TALER_FAKEBANK_make_transfer (
 }
 
 
-uint64_t
-TALER_FAKEBANK_make_admin_transfer (
+/**
+ * Tell the fakebank to create another wire transfer *to* an exchange.
+ *
+ * @param h fake bank handle
+ * @param debit_account account to debit
+ * @param credit_account account to credit
+ * @param amount amount to transfer
+ * @param reserve_pub reserve public key to use in subject
+ * @param[out] serial_id of the transfer
+ * @param[out] timestamp when was the transfer made
+ * @return #GNUNET_OK on success
+ */
+static enum GNUNET_GenericReturnValue
+make_admin_transfer (
   struct TALER_FAKEBANK_Handle *h,
   const char *debit_account,
   const char *credit_account,
   const struct TALER_Amount *amount,
-  const struct TALER_ReservePublicKeyP *reserve_pub)
+  const struct TALER_ReservePublicKeyP *reserve_pub,
+  uint64_t *row_id,
+  struct GNUNET_TIME_Absolute *timestamp)
 {
   struct Transaction *t;
   const struct GNUNET_PeerIdentity *pid;
@@ -824,11 +855,13 @@ TALER_FAKEBANK_make_admin_transfer (
   {
     /* duplicate reserve public key not allowed */
     GNUNET_break (0);
-    return 0;
+    return GNUNET_NO;
   }
 
   ret = __sync_fetch_and_add (&h->serial_counter,
                               1);
+  if (NULL != row_id)
+    *row_id = ret;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Making transfer from %s to %s over %s and subject %s at row 
%llu\n",
               debit_account,
@@ -847,7 +880,9 @@ TALER_FAKEBANK_make_admin_transfer (
   t->amount = *amount;
   t->row_id = ret;
   t->date = GNUNET_TIME_absolute_get ();
-  GNUNET_TIME_round_abs (&t->date);
+  (void) GNUNET_TIME_round_abs (&t->date);
+  if (NULL != timestamp)
+    *timestamp = t->date;
   t->type = T_CREDIT;
   t->subject.credit.reserve_pub = *reserve_pub;
   post_transaction (t);
@@ -863,7 +898,7 @@ TALER_FAKEBANK_make_admin_transfer (
                  pthread_mutex_unlock (&h->rpubs_lock));
   GNUNET_assert (0 ==
                  pthread_mutex_unlock (&t->lock));
-  return ret;
+  return GNUNET_OK;
 }
 
 
@@ -992,6 +1027,8 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
   enum GNUNET_JSON_PostResult pr;
   json_t *json;
   uint64_t row_id;
+  struct GNUNET_TIME_Absolute timestamp;
+  enum GNUNET_GenericReturnValue ret;
 
   pr = GNUNET_JSON_post_parser (REQUEST_BUFFER_MAX,
                                 connection,
@@ -1059,13 +1096,15 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle 
*h,
                 account,
                 TALER_B2S (&reserve_pub),
                 TALER_amount2s (&amount));
-    row_id = TALER_FAKEBANK_make_admin_transfer (h,
-                                                 debit,
-                                                 account,
-                                                 &amount,
-                                                 &reserve_pub);
+    ret = make_admin_transfer (h,
+                               debit,
+                               account,
+                               &amount,
+                               &reserve_pub,
+                               &row_id,
+                               &timestamp);
     GNUNET_free (debit);
-    if (0 == row_id)
+    if (GNUNET_OK != ret)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   "Reserve public key not unique\n");
@@ -1078,8 +1117,6 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle 
*h,
   }
   json_decref (json);
 
-  // FIXME: timestamp without lock is unclean,
-  // return as part of TALER_FAKEBANK_make_admin_transfer instead!
   /* Finally build response object */
   return TALER_MHD_reply_json_pack (connection,
                                     MHD_HTTP_OK,
@@ -1087,8 +1124,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle 
*h,
                                     "row_id",
                                     (json_int_t) row_id,
                                     "timestamp",
-                                    GNUNET_JSON_from_time_abs (
-                                      h->transactions[row_id].date));
+                                    GNUNET_JSON_from_time_abs (timestamp));
 }
 
 
@@ -1172,14 +1208,14 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
       int ret;
 
       credit = TALER_xtalerbank_account_from_payto (credit_account);
-      ret = TALER_FAKEBANK_make_transfer (h,
-                                          account,
-                                          credit,
-                                          &amount,
-                                          &wtid,
-                                          base_url,
-                                          &uuid,
-                                          &row_id);
+      ret = make_transfer (h,
+                           account,
+                           credit,
+                           &amount,
+                           &wtid,
+                           base_url,
+                           &uuid,
+                           &row_id);
       if (GNUNET_OK != ret)
       {
         MHD_RESULT res;
@@ -1393,7 +1429,7 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
   }
   else
   {
-    struct Transaction *t = &h->transactions[ha.start_idx];
+    struct Transaction *t = &h->transactions[ha.start_idx % h->ram_limit];
 
     GNUNET_assert (0 ==
                    pthread_mutex_lock (&t->lock));
@@ -1508,7 +1544,7 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
   }
   else
   {
-    struct Transaction *t = &h->transactions[ha.start_idx];
+    struct Transaction *t = &h->transactions[ha.start_idx % h->ram_limit];
 
     GNUNET_assert (0 ==
                    pthread_mutex_lock (&t->lock));
diff --git a/src/benchmark/benchmark.conf b/src/benchmark/bank-benchmark.conf
similarity index 94%
copy from src/benchmark/benchmark.conf
copy to src/benchmark/bank-benchmark.conf
index 66dfeeca..b36fa794 100644
--- a/src/benchmark/benchmark.conf
+++ b/src/benchmark/bank-benchmark.conf
@@ -28,6 +28,11 @@ DB = postgres
 # exchange (or the twister) is actually listening.
 base_url = "http://localhost:8081/";
 
+WIREWATCH_IDLE_SLEEP_INTERVAL = 5 ms
+
+[exchange-offline]
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+
 [auditor]
 BASE_URL = "http://localhost:8083/";
 
@@ -52,7 +57,7 @@ USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42
 # What is the payto://-URL of the exchange (to generate wire response)
 PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange"
 # What is the bank account (with the "Taler Bank" demo system)? Must end with 
"/".
-WIRE_GATEWAY_URL = http://localhost:8082/taler-wire-gateway/Exchange/
+WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
 # Authentication information for basic authentication
 WIRE_GATEWAY_AUTH_METHOD = "basic"
 username = Exchange
diff --git a/src/benchmark/benchmark.conf b/src/benchmark/benchmark.conf
index 66dfeeca..a5fe4340 100644
--- a/src/benchmark/benchmark.conf
+++ b/src/benchmark/benchmark.conf
@@ -28,6 +28,11 @@ DB = postgres
 # exchange (or the twister) is actually listening.
 base_url = "http://localhost:8081/";
 
+WIREWATCH_IDLE_SLEEP_INTERVAL = 5 ms
+
+[exchange-offline]
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+
 [auditor]
 BASE_URL = "http://localhost:8083/";
 
diff --git a/src/benchmark/taler-bank-benchmark.c 
b/src/benchmark/taler-bank-benchmark.c
index ad46f86d..f3ec074c 100644
--- a/src/benchmark/taler-bank-benchmark.c
+++ b/src/benchmark/taler-bank-benchmark.c
@@ -22,6 +22,10 @@
  * @author Marcello Stanisci
  * @author Christian Grothoff
  */
+// TODO:
+// - use more than one 'client' bank account
+// - also add taler-exchange-transfer to simulate outgoing payments
+// - improve reporting logic (currently not working)
 #include "platform.h"
 #include <gnunet/gnunet_util_lib.h>
 #include <microhttpd.h>
@@ -250,42 +254,39 @@ static void
 run (void *cls,
      struct TALER_TESTING_Interpreter *is)
 {
-  struct TALER_Amount total_reserve_amount;
-  char *user_payto_uri;
+  char *total_reserve_amount;
 
   (void) cls;
   // FIXME: vary user accounts more...
-  GNUNET_assert (GNUNET_OK ==
-                 GNUNET_CONFIGURATION_get_value_string (cfg,
-                                                        "benchmark",
-                                                        "USER_PAYTO_URI",
-                                                        &user_payto_uri));
   all_commands = GNUNET_new_array (howmany_reserves
                                    + 1 /* stat CMD */
                                    + 1 /* End CMD */,
                                    struct TALER_TESTING_Command);
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_amount_get_zero (currency,
-                                        &total_reserve_amount));
-  total_reserve_amount.value = 5;
+  GNUNET_asprintf (&total_reserve_amount,
+                   "%s:5",
+                   currency);
   for (unsigned int j = 0; j < howmany_reserves; j++)
   {
-    char create_reserve_label[32];
-
-    GNUNET_snprintf (create_reserve_label,
-                     sizeof (create_reserve_label),
+    char *create_reserve_label;
+    char *user_payto_uri;
+
+    GNUNET_assert (GNUNET_OK ==
+                   GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                          "benchmark",
+                                                          "USER_PAYTO_URI",
+                                                          &user_payto_uri));
+    GNUNET_asprintf (&create_reserve_label,
                      "createreserve-%u",
                      j);
     all_commands[j]
       = TALER_TESTING_cmd_admin_add_incoming_retry (
           TALER_TESTING_cmd_admin_add_incoming (add_label (
                                                   create_reserve_label),
-                                                TALER_amount2s (
-                                                  &total_reserve_amount),
+                                                total_reserve_amount,
                                                 &exchange_bank_account,
-                                                user_payto_uri));
+                                                add_label (user_payto_uri)));
   }
-  GNUNET_free (user_payto_uri);
+  GNUNET_free (total_reserve_amount);
   all_commands[howmany_reserves]
     = TALER_TESTING_cmd_stat (timings);
   all_commands[howmany_reserves + 1]
@@ -454,6 +455,20 @@ parallel_benchmark (void)
       return GNUNET_SYSERR;
     }
 
+    {
+      struct GNUNET_OS_Process *dbinit;
+
+      dbinit = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
+                                        NULL, NULL, NULL,
+                                        "taler-exchange-dbinit",
+                                        "taler-exchange-dbinit",
+                                        "-c", cfg_filename,
+                                        "-r",
+                                        NULL);
+      GNUNET_break (GNUNET_OK ==
+                    GNUNET_OS_process_wait (dbinit));
+      GNUNET_OS_process_destroy (dbinit);
+    }
     /* start exchange wirewatch */
     wirewatch = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
                                          NULL, NULL, NULL,
@@ -461,21 +476,27 @@ parallel_benchmark (void)
                                          "taler-exchange-wirewatch",
                                          "-c", cfg_filename,
                                          NULL);
-    if (-1 != fakebank)
-    {
-      int wstatus;
-
-      kill (fakebank,
-            SIGTERM);
-      waitpid (fakebank,
-               &wstatus,
-               0);
-    }
-    if (NULL != bankd)
+    if (NULL == wirewatch)
     {
-      GNUNET_OS_process_kill (bankd,
-                              SIGTERM);
-      GNUNET_OS_process_destroy (bankd);
+      if (-1 != fakebank)
+      {
+        int wstatus;
+
+        kill (fakebank,
+              SIGTERM);
+        waitpid (fakebank,
+                 &wstatus,
+                 0);
+        fakebank = -1;
+      }
+      if (NULL != bankd)
+      {
+        GNUNET_OS_process_kill (bankd,
+                                SIGTERM);
+        GNUNET_OS_process_destroy (bankd);
+        bankd = NULL;
+      }
+      return GNUNET_SYSERR;
     }
   }
 
@@ -694,7 +715,7 @@ main (int argc,
              howmany_reserves,
              howmany_clients,
              GNUNET_STRINGS_relative_time_to_string (duration,
-                                                     GNUNET_NO));
+                                                     GNUNET_YES));
     fprintf (stdout,
              "RAW: %04u %04u %16llu\n",
              howmany_reserves,
diff --git a/src/include/taler_fakebank_lib.h b/src/include/taler_fakebank_lib.h
index 60283e7f..864345f3 100644
--- a/src/include/taler_fakebank_lib.h
+++ b/src/include/taler_fakebank_lib.h
@@ -93,51 +93,6 @@ int
 TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h);
 
 
-/**
- * Tell the fakebank to create another wire transfer *from* an exchange.
- *
- * @param h fake bank handle
- * @param debit_account account to debit
- * @param credit_account account to credit
- * @param amount amount to transfer
- * @param subject wire transfer subject to use
- * @param exchange_base_url exchange URL
- * @param request_uid unique number to make the request unique, or NULL to 
create one
- * @param[out] ret_row_id pointer to store the row ID of this transaction
- * @return #GNUNET_YES if the transfer was successful,
- *         #GNUNET_SYSERR if the request_uid was reused for a different 
transfer
- */
-int
-TALER_FAKEBANK_make_transfer (
-  struct TALER_FAKEBANK_Handle *h,
-  const char *debit_account,
-  const char *credit_account,
-  const struct TALER_Amount *amount,
-  const struct TALER_WireTransferIdentifierRawP *subject,
-  const char *exchange_base_url,
-  const struct GNUNET_HashCode *request_uid,
-  uint64_t *ret_row_id);
-
-
-/**
- * Tell the fakebank to create another wire transfer *to* an exchange.
- *
- * @param h fake bank handle
- * @param debit_account account to debit
- * @param credit_account account to credit
- * @param amount amount to transfer
- * @param reserve_pub reserve public key to use in subject
- * @return serial_id of the transfer, 0 on error
- */
-uint64_t
-TALER_FAKEBANK_make_admin_transfer (
-  struct TALER_FAKEBANK_Handle *h,
-  const char *debit_account,
-  const char *credit_account,
-  const struct TALER_Amount *amount,
-  const struct TALER_ReservePublicKeyP *reserve_pub);
-
-
 /**
  * Check that the @a want_amount was transferred from the @a
  * want_debit to the @a want_credit account.  If so, set the @a subject

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