summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-09-15 11:20:27 +0200
committerChristian Grothoff <christian@grothoff.org>2019-09-15 11:20:27 +0200
commit5503c78160d701b85cecfe20af670808becacd39 (patch)
tree254f9aea8c4cf7b9dbe9adb69760d6cecd8dbf27 /src
parent7dca6dacb90390e08df104ad983f8477f0af4a5b (diff)
downloadexchange-5503c78160d701b85cecfe20af670808becacd39.tar.gz
exchange-5503c78160d701b85cecfe20af670808becacd39.tar.bz2
exchange-5503c78160d701b85cecfe20af670808becacd39.zip
remove unused, unclean perf logic (we should measure using the logic in the src/benchmark/ directory anyway)
Diffstat (limited to 'src')
-rw-r--r--src/exchangedb/Makefile.am30
-rw-r--r--src/exchangedb/perf_taler_exchangedb.c382
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.c527
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.h215
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.c1754
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.h1145
-rw-r--r--src/exchangedb/perf_taler_exchangedb_values.h25
-rw-r--r--src/exchangedb/test_perf_taler_exchangedb.c188
8 files changed, 2 insertions, 4264 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 03322f8c..1a866584 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -64,9 +64,7 @@ check_PROGRAMS = \
test-exchangedb-denomkeys \
test-exchangedb-fees \
test-exchangedb-signkeys \
- test-exchangedb-postgres \
- test-perf-taler-exchangedb \
- perf-exchangedb
+ test-exchangedb-postgres
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
@@ -74,8 +72,7 @@ TESTS = \
test-exchangedb-denomkeys \
test-exchangedb-fees \
test-exchangedb-postgres \
- test-exchangedb-signkeys \
- test-perf-taler-exchangedb
+ test-exchangedb-signkeys
test_exchangedb_auditors_SOURCES = \
test_exchangedb_auditors.c
@@ -115,28 +112,5 @@ test_exchangedb_postgres_LDADD = \
-ljansson \
-lgnunetutil
-test_perf_taler_exchangedb_SOURCES = \
- test_perf_taler_exchangedb.c \
- perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \
- perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h
-test_perf_taler_exchangedb_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- $(top_srcdir)/src/pq/libtalerpq.la \
- -lgnunetutil \
- -ljansson
-
-perf_exchangedb_SOURCES = \
- perf_taler_exchangedb.c \
- perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \
- perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h
-perf_exchangedb_LDADD = \
- libtalerexchangedb.la \
- $(top_srcdir)/src/util/libtalerutil.la \
- $(top_srcdir)/src/pq/libtalerpq.la \
- -lgnunetutil \
- -ljansson
-
-
EXTRA_test_exchangedb_postgres_DEPENDENCIES = \
libtaler_plugin_exchangedb_postgres.la
diff --git a/src/exchangedb/perf_taler_exchangedb.c b/src/exchangedb/perf_taler_exchangedb.c
deleted file mode 100644
index 64fde0c1..00000000
--- a/src/exchangedb/perf_taler_exchangedb.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2018 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/perf_taler_exchangedb.c
- * @brief Exchange database performance analysis
- * @author Nicolas Fournier
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "perf_taler_exchangedb_interpreter.h"
-
-
-#define NB_DENOMINATION_INIT 15
-#define NB_DENOMINATION_SAVE 15
-
-#define SMALL 1000
-#define BIG 10000
-#define BIGGER 100000
-
-#define NB_RESERVE_INIT BIGGER
-#define NB_RESERVE_SAVE BIG
-
-#define NB_DEPOSIT_INIT BIGGER
-#define NB_DEPOSIT_SAVE BIG
-
-#define NB_WITHDRAW_INIT BIGGER
-#define NB_WITHDRAW_SAVE BIG
-
-#define NB_REFRESH_INIT BIGGER
-#define NB_REFRESH_SAVE BIG
-
-#define NB_MELT_INIT BIG
-#define NB_MELT_SAVE SMALL
-
-/**
- * Runs the performances tests for the exchange database
- * and logs the results using Gauger
- */
-int
-main (int argc, char **argv)
-{
- int ret;
- struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = {
- /* Denomination used to create coins */
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Initializing database"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop",
- NB_DENOMINATION_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert",
- "01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
- "01 - denomination loop",
- "01 - denomination",
- NB_DENOMINATION_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - end",
- "01 - denomination loop"),
- /* End of initialization */
- /* Reserve initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop",
- NB_RESERVE_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert",
- "02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
- "02 - init reserve loop",
- "02 - reserve",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - end",
- "02 - init reserve loop"),
- /* End reserve init */
- /* Withdrawal initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop",
- NB_WITHDRAW_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
- "03 - init withdraw loop",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
- "03 - init withdraw loop",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw",
- "03 - denomination load",
- "03 - reserve load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert",
- "03 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin",
- "03 - init withdraw loop",
- "03 - withdraw",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - end",
- "03 - init withdraw loop"),
- /*End of withdrawal initialization */
- /*Deposit initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop",
- NB_DEPOSIT_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load",
- "04 - deposit init loop",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit",
- "04 - coin load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert",
- "04 - deposit"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
- "04 - deposit init loop",
- "04 - deposit",
- NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "04 - deposit init loop"),
- /* End of deposit initialization */
- /* Session initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("05 - refresh session init loop",
- NB_REFRESH_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - denomination load",
- "05 - refresh session init loop",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - reserve load",
- "05 - refresh session init loop",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("05 - withdraw",
- "05 - denomination load",
- "05 - reserve load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION (
- "05 - refresh session",
- "05 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("05 - session array",
- "05 - refresh session init loop",
- "05 - refresh session",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("05 - end",
- "05 - refresh session init loop"),
- /* End of refresh session initialization */
- /* Refresh melt initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("06 - refresh melt init loop",
- NB_MELT_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- /* TODO: initialize using coins & sessions created localy
- * in order to make sure the same coin are not melted twice*/
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - session hash",
- "06 - refresh melt init loop",
- "05 - session array"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - coin",
- "06 - refresh melt init loop",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("06 - end",
- "06 - refresh melt init loop"),
- /* End of refresh melt initialization */
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of initialization"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Start of performances measuring"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("21 - reserve insert measure",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("21 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("21 - insert",
- "21 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "21 - reserve insert measure"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("21 - gauger",
- "21 - start",
- "21 - stop",
- "POSTGRES",
- "Number of reserve inserted per second",
- "item/sec",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve insertion"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("22 - reserve load measure",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("22 - reserve",
- "22 - reserve load measure",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE ("22 - get",
- "22 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "22 - reserve load measure"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "22 - start",
- "22 - stop",
- "POSTGRES",
- "Number of reserve loaded per second",
- "item/sec",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve retreival"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("23 - reserve history measure",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("23 - reserve",
- "23 - reserve history measure",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY ("",
- "23 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "23 - reserve history measure"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "23 - start",
- "23 - stop",
- "POSTGRES",
- "Number of reserve history loaded per second",
- "item/sec",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve history access"),
-
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("24 - withdraw insert measure",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - reserve",
- "24 - withdraw insert measure",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - denomination",
- "24 - withdraw insert measure",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("24 - withdraw",
- "24 - denomination",
- "24 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("24 - insert",
- "24 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "24 - withdraw insert measure"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "24 - start",
- "24 - stop",
- "POSTGRES",
- "Number of withdraw insert per second",
- "item/sec",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw insertion"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("25 - withdraw insert measure",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("25 - coin",
- "25 - withdraw insert measure",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW ("",
- "25 - coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "25 - withdraw insert measure"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "25 - start",
- "25 - stop",
- "POSTGRES",
- "Number of withdraw loaded per second",
- "item/sec",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw loading"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("26 - get coin transaction",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("26 - coin",
- "26 - get coin transaction",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION ("",
- "26 - coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "26 - get coin transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - end"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "26 - start",
- "26 - end",
- "POSTGRES",
- "Number of coin transaction history loaded per second",
- "item/sec",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of transaction loading"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("27 - /reserve/withdraw",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - reserve",
- "27 - /reserve/withdraw",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - dki",
- "27 - /reserve/withdraw",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN ("",
- "27 - dki",
- "27 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "27 - /reserve/withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - end"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "27 - start",
- "27 - end",
- "POSTGRES",
- "Number of /reserve/withdraw per second",
- "item/sec",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("28 - /deposit",
- NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("28 - coin",
- "28 - /deposit",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT ("28 - deposit",
- "28 - coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "28 - /deposit"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "28 - start",
- "28 - stop",
- "POSTGRES",
- "Number of /deposit per second",
- "item/sec",
- NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("29 - insert refresh session",
- NB_REFRESH_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - denomination load",
- "29 - insert refresh session",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - reserve load",
- "29 - insert refresh session",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("29 - withdraw",
- "29 - denomination load",
- "29 - reserve load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION (
- "29 - refresh session",
- "29 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("29 - session array",
- "29 - insert refresh session",
- "29 - refresh session",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "29 - insert refresh session"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("",
- "29 - start",
- "29 - stop",
- "POSTGRES",
- "Number of refresh session inserted per second",
- "item/sec",
- NB_REFRESH_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END (""),
- };
-
- ret = PERF_TALER_EXCHANGEDB_run_benchmark (
- "perf-taler-exchangedb",
- "./test-exchange-db-postgres.conf",
- (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END (
- "")},
- benchmark);
- if (GNUNET_SYSERR == ret)
- return 1;
- return 0;
-}
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c
deleted file mode 100644
index d27634bd..00000000
--- a/src/exchangedb/perf_taler_exchangedb_init.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/perf_taler_exchangedb_init.c
- * @brief Interpreter library for exchange database performance analysis
- * @author Nicolas Fournier
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "perf_taler_exchangedb_init.h"
-#include <gnunet/gnunet_signatures.h>
-#include "taler_signatures.h"
-#include "taler_amount_lib.h"
-
-
-#define CURRENCY "EUR"
-#define PERF_TALER_EXCHANGEDB_RSA_SIZE 512
-
-
-/**
- * Generate a dummy DenominationKeyInformation for testing purposes
- * @return a dummy denomination key
- */
-struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
-PERF_TALER_EXCHANGEDB_denomination_init ()
-{
- struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt;
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
- struct TALER_DenominationPrivateKey denom_priv;
- struct TALER_DenominationPublicKey denom_pub;
- struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
-
- master_prvt = GNUNET_CRYPTO_eddsa_key_create ();
-
- dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation);
- GNUNET_assert (NULL != dki);
- denom_priv.rsa_private_key
- = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_EXCHANGEDB_RSA_SIZE);
- GNUNET_assert (NULL != denom_priv.rsa_private_key);
- denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key);
- GNUNET_assert (NULL != denom_pub.rsa_public_key);
- {/* issue */
- struct TALER_MasterSignatureP signature;
- struct TALER_DenominationKeyValidityPS properties;
-
- {/* properties */
- struct TALER_Amount amount;
- struct GNUNET_TIME_Absolute now;
-
- properties.purpose.purpose = htonl (
- TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
- properties.purpose.size = htonl (sizeof (struct
- TALER_DenominationKeyValidityPS));
- GNUNET_CRYPTO_eddsa_key_get_public (master_prvt,
- &properties.master.eddsa_pub);
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
- properties.start = GNUNET_TIME_absolute_hton (now);
- properties.expire_withdraw = GNUNET_TIME_absolute_hton (
- GNUNET_TIME_UNIT_FOREVER_ABS);
- properties.expire_deposit = GNUNET_TIME_absolute_hton (
- GNUNET_TIME_UNIT_FOREVER_ABS);
- properties.expire_legal = GNUNET_TIME_absolute_hton (
- GNUNET_TIME_UNIT_FOREVER_ABS);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1", &amount));
- TALER_amount_hton (&properties.value, &amount);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":0.1", &amount));
- TALER_amount_hton (&properties.fee_withdraw, &amount);
- TALER_amount_hton (&properties.fee_deposit, &amount);
- TALER_amount_hton (&properties.fee_refresh, &amount);
- TALER_amount_hton (&properties.fee_refund, &amount);
- GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key,
- &properties.denom_hash);
- issue.properties = properties;
- }
- {/* signature */
- GNUNET_CRYPTO_eddsa_sign (master_prvt,
- &properties.purpose,
- &signature.eddsa_signature);
- issue.signature = signature;
- }
- }
- dki->denom_priv = denom_priv;
- dki->denom_pub = denom_pub;
- dki->issue = issue;
- GNUNET_free (master_prvt);
- return dki;
-}
-
-
-/**
- * Copies the given denomination
- * @param reserve the deposit copy
- * @return a copy of @a deposit; NULL if error
- */
-struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
-PERF_TALER_EXCHANGEDB_denomination_copy (const struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation
- *dki)
-{
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy;
-
- GNUNET_assert (NULL !=
- (copy = GNUNET_new (struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation)));
- {/* denom_priv */
- copy->denom_priv.rsa_private_key =
- GNUNET_CRYPTO_rsa_private_key_dup (dki->denom_priv.rsa_private_key);
- }
- {/* denom_pub */
- copy->denom_pub.rsa_public_key =
- GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key);
- }
- {/* issue */
- copy->issue.properties = dki->issue.properties;
- copy->issue.signature = dki->issue.signature;
- }
- return copy;
-}
-
-
-/**
- * Free memory of a DenominationKeyIssueInformation
- * @param dki pointer to the struct to free
- */
-int
-PERF_TALER_EXCHANGEDB_denomination_free (struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation
- *dki)
-{
- if (NULL == dki)
- return GNUNET_OK;
- GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key);
- GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key);
-
- GNUNET_free (dki);
- return GNUNET_OK;
-}
-
-
-/**
- * Generate a dummy reserve for testing
- * @return a reserve with 1000 EUR in it
- */
-struct PERF_TALER_EXCHANGEDB_Reserve *
-PERF_TALER_EXCHANGEDB_reserve_init ()
-{
- struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
-
- GNUNET_assert (NULL !=
- (reserve = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve)));
- {/* private */
- struct GNUNET_CRYPTO_EddsaPrivateKey *private;
- private = GNUNET_CRYPTO_eddsa_key_create ();
- GNUNET_assert (NULL != private);
- reserve->private = *private;
- GNUNET_free (private);
- }
-
- GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private,
- &reserve->reserve.pub.eddsa_pub);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1000",
- &reserve->reserve.balance));
- reserve->reserve.expiry = GNUNET_TIME_UNIT_FOREVER_ABS;
- return reserve;
-}
-
-
-/**
- * Copies the given reserve
- * @param reserve the reserve to copy
- * @return a copy of @a reserve; NULL if error
- */
-struct PERF_TALER_EXCHANGEDB_Reserve *
-PERF_TALER_EXCHANGEDB_reserve_copy (const struct
- PERF_TALER_EXCHANGEDB_Reserve *reserve)
-{
- struct PERF_TALER_EXCHANGEDB_Reserve *copy;
- GNUNET_assert (NULL !=
- (copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve)));
- *copy = *reserve;
- return copy;
-}
-
-
-/**
- * Free memory of a reserve
- * @param reserve pointer to the structure to be freed
- */
-int
-PERF_TALER_EXCHANGEDB_reserve_free (struct
- PERF_TALER_EXCHANGEDB_Reserve *reserve)
-{
- if (NULL == reserve)
- return GNUNET_OK;
- GNUNET_free (reserve);
- return GNUNET_OK;
-}
-
-
-/**
- * Generate a dummy deposit for testing purposes
- *
- * @param dki the denomination key used to sign the key
- */
-struct TALER_EXCHANGEDB_Deposit *
-PERF_TALER_EXCHANGEDB_deposit_init (const struct
- PERF_TALER_EXCHANGEDB_Coin *coin)
-{
- struct TALER_EXCHANGEDB_Deposit *deposit;
- struct TALER_CoinSpendSignatureP csig;
- struct TALER_MerchantPublicKeyP merchant_pub;
- struct GNUNET_HashCode h_contract_terms;
- struct GNUNET_HashCode h_wire;
- struct GNUNET_TIME_Absolute timestamp;
- struct GNUNET_TIME_Absolute refund_deadline;
- struct TALER_Amount amount_with_fee;
- struct TALER_Amount deposit_fee;
-
- deposit = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
- &h_contract_terms);
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
- &h_wire);
- { // csig
- struct u32_presign
- {
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
- struct GNUNET_HashCode h_wire;
- struct GNUNET_HashCode h_contract_terms;
- } unsigned_data;
-
- unsigned_data.h_contract_terms = h_contract_terms;
- unsigned_data.h_wire = h_wire;
- unsigned_data.purpose.size = htonl (sizeof (struct u32_presign));
- unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (&coin->priv,
- &unsigned_data.purpose,
- &csig.eddsa_signature));
- }
- { // merchant_pub
- struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv;
-
- eddsa_prv = GNUNET_CRYPTO_eddsa_key_create ();
- GNUNET_assert (NULL != eddsa_prv);
- GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prv,
- &merchant_pub.eddsa_pub);
- GNUNET_free (eddsa_prv);
- }
- timestamp = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&timestamp);
- refund_deadline = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&refund_deadline);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &amount_with_fee));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":0.1",
- &deposit_fee));
- {
- deposit->coin.coin_pub = coin->public_info.coin_pub;
- deposit->coin.denom_pub_hash = coin->public_info.denom_pub_hash;
- deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (
- coin->public_info.denom_sig.rsa_signature);
- GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature);
- }
- deposit->csig = csig;
- deposit->h_contract_terms = h_contract_terms;
- deposit->h_wire = h_wire;
- deposit->receiver_wire_account
- = json_pack ("{s:s, s:s}",
- "url", "payto://iban/DE67830654080004822650",
- "salt", "this-is-a-salt-value");
- deposit->timestamp = timestamp;
- deposit->refund_deadline = refund_deadline;
- deposit->amount_with_fee = amount_with_fee;
- deposit->deposit_fee = deposit_fee;
- return deposit;
-}
-
-
-/**
- * Copies the given deposit
- * @param reserve the deposit copy
- * @return a copy of @a deposit; NULL if error
- */
-struct TALER_EXCHANGEDB_Deposit *
-PERF_TALER_EXCHANGEDB_deposit_copy (const struct
- TALER_EXCHANGEDB_Deposit *deposit)
-{
- struct TALER_EXCHANGEDB_Deposit *copy;
-
- copy = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
- *copy = *deposit;
- copy->receiver_wire_account = json_incref (deposit->receiver_wire_account);
- copy->coin.denom_sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (deposit->coin.denom_sig.rsa_signature);
- return copy;
-}
-
-
-/**
- * Free memory of a deposit
- * @param deposit pointer to the structure to free
- */
-int
-PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit)
-{
- if (NULL == deposit)
- return GNUNET_OK;
- GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
- json_decref (deposit->receiver_wire_account);
- GNUNET_free (deposit);
- return GNUNET_OK;
-}
-
-
-/**
- * Generate a CollectableBlindcoin for testing purpuses
- * @param dki denomination key used to sign the coin
- * @param reserve reserve providing the money for the coin
- * @return a randomly generated CollectableBlindcoin
- */
-struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_init (
- const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki,
- const struct PERF_TALER_EXCHANGEDB_Reserve *reserve)
-{
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
- struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
- struct GNUNET_HashCode hc;
-
- coin = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin);
- GNUNET_assert (NULL != coin);
- /* priv */
-
- priv = GNUNET_CRYPTO_eddsa_key_create ();
- GNUNET_assert (NULL != priv);
- coin->priv = *priv;
- GNUNET_free (priv);
-
- /* public_info */
- GNUNET_CRYPTO_eddsa_key_get_public (&coin->priv,
- &coin->public_info.coin_pub.eddsa_pub);
- GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
- &coin->public_info.denom_pub_hash);
- GNUNET_CRYPTO_hash (&coin->public_info.coin_pub,
- sizeof (struct TALER_CoinSpendPublicKeyP),
- &hc);
- coin->public_info.denom_sig.rsa_signature =
- GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key,
- &hc);
- GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature);
-
- /* blind */
- coin->blind.sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
- coin->blind.denom_pub_hash = coin->public_info.denom_pub_hash;
- GNUNET_assert (NULL != coin->blind.sig.rsa_signature);
- TALER_amount_ntoh (&coin->blind.amount_with_fee,
- &dki->issue.properties.value);
- TALER_amount_ntoh (&coin->blind.withdraw_fee,
- &dki->issue.properties.fee_withdraw);
- coin->blind.reserve_pub = reserve->reserve.pub;
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
- &coin->blind.h_coin_envelope);
-
- return coin;
-}
-
-
-/**
- * Copies the given coin
- *
- * @param coin the coin to copy
- * @return a copy of coin; NULL if error
- */
-struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin)
-{
- struct PERF_TALER_EXCHANGEDB_Coin *copy;
-
- copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin);
- /* priv */
- copy->priv = coin->priv;
- /* public_info */
- copy->public_info.coin_pub = coin->public_info.coin_pub;
- copy->public_info.denom_pub_hash = coin->public_info.denom_pub_hash;
- copy->public_info.denom_sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
-
- /* blind */
- copy->blind.sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (coin->blind.sig.rsa_signature);
- copy->blind.denom_pub_hash = coin->blind.denom_pub_hash;
- copy->blind.amount_with_fee = coin->blind.amount_with_fee;
- copy->blind.withdraw_fee = coin->blind.withdraw_fee;
- copy->blind.reserve_pub = coin->blind.reserve_pub;
- copy->blind.h_coin_envelope = coin->blind.h_coin_envelope;
- copy->blind.reserve_sig = coin->blind.reserve_sig;
-
- return copy;
-}
-
-
-/**
- * Free memory of @a coin
- *
- * @param coin pointer to the structure to free
- */
-int
-PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin)
-{
- if (NULL == coin)
- return GNUNET_OK;
- GNUNET_CRYPTO_rsa_signature_free (coin->public_info.denom_sig.rsa_signature);
- GNUNET_CRYPTO_rsa_signature_free (coin->blind.sig.rsa_signature);
- GNUNET_free (coin);
- return GNUNET_OK;
-}
-
-
-/**
- * Create a melt operation
- *
- * @param rc the commitment of the refresh session
- * @param dki the denomination the melted coin uses
- * @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt
- */
-struct TALER_EXCHANGEDB_RefreshMelt *
-PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc,
- struct PERF_TALER_EXCHANGEDB_Coin *coin)
-{
- struct TALER_EXCHANGEDB_RefreshMelt *melt;
- struct TALER_CoinSpendSignatureP coin_sig;
- struct TALER_Amount amount;
- struct TALER_Amount amount_with_fee;
-
- {
- struct
- {
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
- struct TALER_RefreshCommitmentP rc;
- } to_sign;
-
- to_sign.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
- to_sign.purpose.size = htonl (sizeof (to_sign));
- to_sign.rc = *rc;
- GNUNET_CRYPTO_eddsa_sign (&coin->priv,
- &to_sign.purpose,
- &coin_sig.eddsa_signature);
- }
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &amount));
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":0.1",
- &amount_with_fee));
- melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt);
- melt->session.coin.coin_pub = coin->public_info.coin_pub;
- melt->session.coin.denom_sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
- melt->session.coin.denom_pub_hash = coin->public_info.denom_pub_hash;
- GNUNET_assert (NULL != melt->session.coin.denom_sig.rsa_signature);
- melt->session.coin_sig = coin_sig;
- melt->session.rc = *rc;
- melt->session.amount_with_fee = amount;
- melt->melt_fee = amount_with_fee;
- return melt;
-}
-
-
-/**
- * Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt
- *
- * @param melt the refresh melt to copy
- * @return an copy of @ melt
- */
-struct TALER_EXCHANGEDB_RefreshMelt *
-PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct
- TALER_EXCHANGEDB_RefreshMelt *melt)
-{
- struct TALER_EXCHANGEDB_RefreshMelt *copy;
-
- copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt);
- *copy = *melt;
- copy->session.coin.denom_sig.rsa_signature =
- GNUNET_CRYPTO_rsa_signature_dup (
- melt->session.coin.denom_sig.rsa_signature);
- GNUNET_assert (NULL != copy->session.coin.denom_sig.rsa_signature);
-
- return copy;
-}
-
-
-/**
- * Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt
- *
- * @param melt the #TALER_EXCHANGEDB_RefreshMelt to free
- * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR
- */
-int
-PERF_TALER_EXCHANGEDB_refresh_melt_free (struct
- TALER_EXCHANGEDB_RefreshMelt *melt)
-{
- GNUNET_CRYPTO_rsa_signature_free (melt->session.coin.denom_sig.rsa_signature);
- GNUNET_free (melt);
- return GNUNET_OK;
-}
diff --git a/src/exchangedb/perf_taler_exchangedb_init.h b/src/exchangedb/perf_taler_exchangedb_init.h
deleted file mode 100644
index f20b35c5..00000000
--- a/src/exchangedb/perf_taler_exchangedb_init.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/perf_taler_exchangedb_init.h
- * @brief Heler function for creating dummy inputs for the exchange database
- * @author Nicolas Fournier
- */
-#ifndef __PERF_TALER_EXCHANGEDB_INIT_H___
-#define __PERF_TALER_EXCHANGEDB_INIT_H___
-
-#include "taler_exchangedb_plugin.h"
-
-
-#define CURRENCY "EUR"
-
-/**
- * All information about a reserve
- */
-struct PERF_TALER_EXCHANGEDB_Reserve
-{
- /**
- * Information about a rserve available to the Exchange
- */
- struct TALER_EXCHANGEDB_Reserve reserve;
-
- /**
- * Private key of a reserve
- */
- struct GNUNET_CRYPTO_EddsaPrivateKey private;
-};
-
-
-/**
- * All informations about a coin
- */
-struct PERF_TALER_EXCHANGEDB_Coin
-{
- /**
- * Blinded coin, known by the exchange
- */
- struct TALER_EXCHANGEDB_CollectableBlindcoin blind;
-
- /**
- * Public key of the coin and othes informations
- */
- struct TALER_CoinPublicInfo public_info;
-
- /**
- * Private key of the coin
- */
- struct GNUNET_CRYPTO_EddsaPrivateKey priv;
-};
-
-
-/**
- * Generate a dummy DenominationKeyInformation for testing purposes
- * @return a dummy denomination key
- */
-struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
-PERF_TALER_EXCHANGEDB_denomination_init (void);
-
-
-/**
- * Copies the given denomination
- * @param reserve the deposit copy
- * @return a copy of @a deposit; NULL if error
- */
-struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
-PERF_TALER_EXCHANGEDB_denomination_copy (const struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation
- *dki);
-
-
-/**
- * Free memory of a DenominationKeyIssueInformation
- * @param dki pointer to the struct to free
- */
-int
-PERF_TALER_EXCHANGEDB_denomination_free (struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation
- *dki);
-
-
-/**
- * Generate a dummy reserve for testing
- * @return a reserve with 1000 EUR in it
- */
-struct PERF_TALER_EXCHANGEDB_Reserve *
-PERF_TALER_EXCHANGEDB_reserve_init (void);
-
-
-/**
- * Copies the given reserve
- * @param reserve the reserve to copy
- * @return a copy of @a reserve; NULL if error
- */
-struct PERF_TALER_EXCHANGEDB_Reserve *
-PERF_TALER_EXCHANGEDB_reserve_copy (const struct
- PERF_TALER_EXCHANGEDB_Reserve *reserve);
-
-
-/**
- * Free memory of a reserve
- * @param reserve pointer to the structure to be freed
- */
-int
-PERF_TALER_EXCHANGEDB_reserve_free (struct
- PERF_TALER_EXCHANGEDB_Reserve *reserve);
-
-
-/**
- * Generate a dummy deposit for testing purposes
- * @param dki the denomination key used to sign the key
- */
-struct TALER_EXCHANGEDB_Deposit *
-PERF_TALER_EXCHANGEDB_deposit_init (const struct
- PERF_TALER_EXCHANGEDB_Coin *coin);
-
-
-/**
- * Copies the given deposit
- * @param reserve the deposit copy
- * @return a copy of @a deposit; NULL if error
- */
-struct TALER_EXCHANGEDB_Deposit *
-PERF_TALER_EXCHANGEDB_deposit_copy (const struct
- TALER_EXCHANGEDB_Deposit *deposit);
-
-
-/**
- * Free memory of a deposit
- * @param deposit pointer to the structure to free
- */
-int
-PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit);
-
-
-/**
- * Generate a coin for testing purpuses
- * @param dki denomination key used to sign the coin
- * @param reserve reserve providing the money for the coin
- * @return a randomly generated CollectableBlindcoin
- */
-struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_init (const struct
- TALER_EXCHANGEDB_DenominationKeyIssueInformation
- *dki,
- const struct
- PERF_TALER_EXCHANGEDB_Reserve *reserve);
-
-
-/**
- * Copies the given coin
- * @param coin the coin to copy
- * @return a copy of coin; NULL if error
- */
-struct PERF_TALER_EXCHANGEDB_Coin *
-PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
-
-
-/**
- * Liberate memory of @a coin
- * @param coin pointer to the structure to free
- */
-int
-PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin);
-
-
-/**
- * Create a melt operation
- *
- * @param rc the commitment of the refresh session
- * @param dki the denomination the melted coin uses
- * @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt
- */
-struct TALER_EXCHANGEDB_RefreshMelt *
-PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc,
- struct PERF_TALER_EXCHANGEDB_Coin *coin);
-
-
-/**
- * Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt
- *
- * @param melt the refresh melt to copy
- * @return an copy of @ melt
- */
-struct TALER_EXCHANGEDB_RefreshMelt *
-PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct
- TALER_EXCHANGEDB_RefreshMelt *melt);
-
-
-/**
- * Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt
- *
- * @param melt the #TALER_EXCHANGEDB_RefreshMelt to free
- * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR
- */
-int
-PERF_TALER_EXCHANGEDB_refresh_melt_free (struct
- TALER_EXCHANGEDB_RefreshMelt *melt);
-
-#endif
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c
deleted file mode 100644
index b96db493..00000000
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.c
+++ /dev/null
@@ -1,1754 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2017 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/perf_taler_exchangedb_interpreter.c
- * @brief Interpreter library for exchange database performance analysis
- * @author Nicolas Fournier
- */
-#include "platform.h"
-#include "perf_taler_exchangedb_interpreter.h"
-#include "perf_taler_exchangedb_init.h"
-#include "gauger.h"
-
-
-/**
- * Represents the state of the interpreter
- */
-struct PERF_TALER_EXCHANGEDB_interpreter_state
-{
- /**
- * State of the commands
- */
- struct PERF_TALER_EXCHANGEDB_Cmd *cmd;
-
- /**
- * Database plugin
- */
- struct TALER_EXCHANGEDB_Plugin *plugin;
-
- /**
- * Current database session
- */
- struct TALER_EXCHANGEDB_Session *session;
-
- /**
- * The current index of the interpreter
- */
- unsigned int i;
-};
-
-
-/**
- * Free the memory of @a data
- */
-static void
-data_free (struct PERF_TALER_EXCHANGEDB_Data *data)
-{
- switch (data->type)
- {
- case PERF_TALER_EXCHANGEDB_TIME:
- if (NULL == data->data.time)
- break;
- GNUNET_free (data->data.time);
- data->data.time = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_DEPOSIT:
- if (NULL == data->data.deposit)
- break;
- PERF_TALER_EXCHANGEDB_deposit_free (data->data.deposit);
- data->data.deposit = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_COIN:
- if (NULL == data->data.coin)
- break;
- GNUNET_free (data->data.coin);
- data->data.coin = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_RESERVE:
- if (NULL == data->data.reserve)
- break;
- PERF_TALER_EXCHANGEDB_reserve_free (data->data.reserve);
- data->data.reserve = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO:
- if (NULL == data->data.dki)
- break;
- PERF_TALER_EXCHANGEDB_denomination_free (data->data.dki);
- data->data.dki = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_REFRESH_HASH:
- break;
- case PERF_TALER_EXCHANGEDB_NONE:
- break;
- }
-}
-
-
-/**
- * Copies @a data into @a copy
- *
- * @param data the data to be copied
- * @param[out] copy the copy made
- */
-static void
-data_copy (const struct PERF_TALER_EXCHANGEDB_Data *data,
- struct PERF_TALER_EXCHANGEDB_Data *copy)
-{
- copy->type = data->type;
- switch (data->type)
- {
- case PERF_TALER_EXCHANGEDB_TIME:
- copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute);
- *copy->data.time = *data->data.time;
- return;
- case PERF_TALER_EXCHANGEDB_DEPOSIT:
- copy->data.deposit
- = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit);
- return;
- case PERF_TALER_EXCHANGEDB_COIN:
- copy->data.coin
- = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin);
- return;
- case PERF_TALER_EXCHANGEDB_RESERVE:
- copy->data.reserve
- = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve);
- return;
- case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO:
- copy->data.dki
- = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki);
- return;
- case PERF_TALER_EXCHANGEDB_REFRESH_HASH:
- copy->data.rc = data->data.rc;
- break;
- case PERF_TALER_EXCHANGEDB_NONE:
- break;
- }
-}
-
-
-/**
- * Finds the first command in cmd with the name search
- *
- * @return the index of the first command with name search
- * #GNUNET_SYSERR if none found
- */
-static int
-cmd_find (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd,
- const char *search)
-{
- unsigned int i;
-
- for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++)
- if (0 == strcmp (cmd[i].label, search))
- return i;
- return GNUNET_SYSERR;
-}
-
-
-/**
- * Initialization of a command array
- * and check for the type of the label
- *
- * @param cmd the comand array initialized
- * @return #GNUNET_OK if the initialization was sucessful
- * #GNUNET_SYSERR if there was a probleb. See the log for details
- */
-static int
-cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
-{
- unsigned int i;
-
- for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++)
- {
- switch (cmd[i].command)
- {
- case PERF_TALER_EXCHANGEDB_CMD_END_LOOP:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.end_loop.label_loop);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.end_loop.label_loop);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.end_loop.label_loop,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.end_loop.index_loop = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.save_array.label_save);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s at %s\n",
- i,
- cmd[i].details.save_array.label_save,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.save_array.label_save,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.save_array.index_save = ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.save_array.label_loop);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s at %s\n",
- i,
- cmd[i].details.save_array.label_loop,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.save_array.label_loop,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.save_array.index_loop = ret;
-
- GNUNET_assert (NULL == cmd[i].details.save_array.data_saved);
- cmd[i].details.save_array.data_saved =
- GNUNET_new_array (cmd[i].details.save_array.nb_saved,
- struct PERF_TALER_EXCHANGEDB_Data);
- cmd[i].details.save_array.type_saved =
- cmd[cmd[i].details.save_array.index_save].exposed.type;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.load_array.label_save);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s at %s\n",
- i,
- cmd[i].details.load_array.label_save,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.load_array.label_save,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.load_array.index_save = ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.load_array.label_loop);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.load_array.label_loop);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.load_array.label_loop);
- return GNUNET_SYSERR;
- }
- cmd[i].details.load_array.index_loop = ret;
-
- cmd[i].details.load_array.permutation =
- GNUNET_CRYPTO_random_permute (
- GNUNET_CRYPTO_QUALITY_WEAK,
- cmd[cmd[i].details.load_array.index_save].details.save_array.
- nb_saved);
- GNUNET_assert (NULL != cmd[i].details.load_array.permutation);
-
- cmd[i].exposed.type =
- cmd[cmd[i].details.load_array.index_save].details.save_array.
- type_saved;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.load_random.label_save);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.load_random.label_save);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.load_random.label_save);
- return GNUNET_SYSERR;
- }
- cmd[i].details.load_random.index_save = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GAUGER:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.gauger.label_start);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.gauger.label_start);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.gauger.label_start);
- return GNUNET_SYSERR;
- }
- cmd[i].details.gauger.index_start = ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.gauger.label_stop);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.gauger.label_stop);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.gauger.label_stop);
- return GNUNET_SYSERR;
- }
- cmd[i].details.gauger.index_stop = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.insert_denomination.label_denom);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_denomination.label_denom);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_denomination.label_denom);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_denomination.index_denom = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_denomination.label_denom);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_denomination.label_denom);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_denomination.label_denom);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_denomination.index_denom = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.insert_reserve.label_reserve);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_reserve.label_reserve);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_reserve.label_reserve);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_reserve.index_reserve = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_reserve.label_reserve);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_reserve.label_reserve);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_reserve.label_reserve);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_reserve.index_reserve = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_reserve_history.label_reserve);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_reserve_history.label_reserve);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_reserve_history.label_reserve);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_reserve_history.index_reserve = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.create_withdraw.label_dki);
- {
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.create_withdraw.label_dki);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.create_withdraw.label_dki);
- return GNUNET_SYSERR;
- }
- }
- cmd[i].details.create_withdraw.index_dki = ret;
- ret = cmd_find (cmd,
- cmd[i].details.create_withdraw.label_reserve);
- {
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.create_withdraw.label_reserve);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.create_withdraw.label_reserve);
- return GNUNET_SYSERR;
- }
- }
- cmd[i].details.create_withdraw.index_reserve = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.insert_withdraw.label_coin);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_withdraw.label_coin);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_withdraw.label_coin);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_withdraw.index_coin = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_withdraw.label_coin);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_withdraw.label_coin);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_withdraw.label_coin);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_withdraw.index_coin = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION:
- {
- int ret;
- ret = cmd_find (cmd,
- cmd[i].details.get_coin_transaction.label_coin);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_coin_transaction.label_coin);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_coin_transaction.label_coin);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_coin_transaction.index_coin = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.create_deposit.label_coin);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.create_deposit.label_coin);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.create_deposit.label_coin);
- return GNUNET_SYSERR;
- }
- cmd[i].details.create_deposit.index_coin = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.insert_deposit.label_deposit);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_deposit.label_deposit);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_deposit.label_deposit);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_deposit.index_deposit = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_deposit.label_deposit);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_deposit.label_deposit);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_deposit.label_deposit);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_deposit.index_deposit = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.create_refresh_session.label_coin);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s at %s\n",
- i,
- cmd[i].details.create_refresh_session.label_coin,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.create_refresh_session.label_coin,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.create_refresh_session.index_coin = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION:
- {
- int ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.get_refresh_session.label_hash);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s at %s\n",
- i,
- cmd[i].details.get_refresh_session.label_hash,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s at %s\n",
- i,
- cmd[i].details.get_refresh_session.label_hash,
- cmd[i].label);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_refresh_session.index_hash = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL:
- {
- int ret;
- ret = cmd_find (cmd,
- cmd[i].details.insert_refresh_reveal.label_hash);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_refresh_reveal.label_hash);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_refresh_reveal.label_hash);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_refresh_reveal.index_hash = ret;
-
- ret = cmd_find (cmd,
- cmd[i].details.insert_refresh_reveal.label_denom);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.insert_refresh_reveal.label_denom);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.insert_refresh_reveal.label_denom);
- return GNUNET_SYSERR;
- }
- cmd[i].details.insert_refresh_reveal.index_denom = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL:
- {
- int ret;
- ret = cmd_find (cmd,
- cmd[i].details.get_refresh_reveal.label_hash);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_refresh_reveal.label_hash);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_refresh_reveal.label_hash);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_refresh_reveal.index_hash = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA:
- {
- int ret;
- ret = cmd_find (cmd,
- cmd[i].details.get_link_data_list.label_hash);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Undefined reference to %s\n",
- i,
- cmd[i].details.get_link_data_list.label_hash);
- return GNUNET_SYSERR;
- }
- if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%d:Wrong type reference to %s\n",
- i,
- cmd[i].details.get_link_data_list.label_hash);
- return GNUNET_SYSERR;
- }
- cmd[i].details.get_link_data_list.index_hash = ret;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_END:
- case PERF_TALER_EXCHANGEDB_CMD_DEBUG:
- case PERF_TALER_EXCHANGEDB_CMD_LOOP:
- case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION:
- case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
- case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION:
- case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION:
- case PERF_TALER_EXCHANGEDB_CMD_GET_TIME:
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION:
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE:
- break;
- }
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Free the memory of the command chain
- */
-static int
-cmd_clean (struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
-{
- for (unsigned int i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++)
- {
- switch (cmd[i].command)
- {
- case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY:
- {
- for (unsigned int j = 0; j < cmd[i].details.save_array.nb_saved; j++)
- {
- data_free (&cmd[i].details.save_array.data_saved[j]);
- }
- GNUNET_free (cmd[i].details.save_array.data_saved);
- cmd[i].details.save_array.data_saved = NULL;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY:
- GNUNET_free (cmd[i].details.load_array.permutation);
- cmd[i].details.load_array.permutation = NULL;
- break;
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW:
- PERF_TALER_EXCHANGEDB_coin_free (cmd[i].exposed.data.coin);
- break;
- default:
- break;
- }
- data_free (&cmd[i].exposed);
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Handles the command #PERF_TALER_EXCHANGEDB_CMD_END_LOOP for the interpreter
- * Cleans the memory at the end of the loop
- */
-static void
-interpret_end_loop (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
-{
- int jump;
-
- jump = state->cmd[state->i].details.end_loop.index_loop;
- // Cleaning up the memory in the loop
- for (unsigned int i = jump; i < state->i; i++)
- data_free (&state->cmd[i].exposed);
-
- state->cmd[jump].details.loop.curr_iteration++;
- /* If the loop is not finished */
- if (state->cmd[jump].details.loop.max_iterations >
- state->cmd[jump].details.loop.curr_iteration)
- {
- /* jump back to the start */
- state->i = jump;
- }
- else
- {
- /* Reset the loop counter and continue running */
- state->cmd[jump].details.loop.curr_iteration = 0;
- }
-}
-
-
-/**
- * Part of the interpreter specific to
- * #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY
- * Saves the data exposed by another command into
- * an array in the command specific struct.
- */
-static void
-interpret_save_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
-{
- struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i];
- struct PERF_TALER_EXCHANGEDB_Cmd *save_ref;
- struct PERF_TALER_EXCHANGEDB_Cmd *loop_ref;
- int loop_index;
- int save_index;
- unsigned int selection_chance;
-
- loop_index = cmd->details.save_array.index_loop;
- save_index = cmd->details.save_array.index_save;
- loop_ref = &state->cmd[loop_index];
- save_ref = &state->cmd[save_index];
- /* Array initialization on first loop iteration
- Alows for nested loops */
- if (0 == cmd->details.loop.curr_iteration)
- {
- cmd->details.save_array.index = 0;
- }
- /* The probability distribution of the saved items will be a little biased
- against the few last items but it should not be a big problem. */
- selection_chance = loop_ref->details.loop.max_iterations
- / cmd->details.save_array.nb_saved;
- /*
- * If the remaining space is equal to the remaining number of
- * iterations, the item is automaticly saved.
- *
- * Else it is saved only if the random numbre generated is 0
- */
- if ( (0 < (cmd->details.save_array.nb_saved
- - cmd->details.save_array.index) ) &&
- ( ((loop_ref->details.loop.max_iterations
- - loop_ref->details.loop.curr_iteration) ==
- (cmd->details.save_array.nb_saved
- - cmd->details.save_array.index)) ||
- (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- selection_chance)) ) )
- {
- struct PERF_TALER_EXCHANGEDB_Data *save_location;
- struct PERF_TALER_EXCHANGEDB_Data *item_saved;
-
- save_location =
- &cmd->details.save_array.data_saved[cmd->details.save_array.index];
- item_saved = &save_ref->exposed;
- data_copy (item_saved, save_location);
- cmd->details.save_array.index++;
- }
-}
-
-
-/**
- * Part of the interpreter specific to
- * #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY
- * Gets data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY and exposes a copy
- */
-static void
-interpret_load_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
-{
- struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i];
- unsigned int loop_iter;
- int loop_index;
- int save_index;
- struct PERF_TALER_EXCHANGEDB_Data *loaded_data;
-
- loop_index = cmd->details.load_array.index_loop;
- save_index = cmd->details.load_array.index_save;
- loop_iter = state->cmd[loop_index].details.loop.curr_iteration;
- {
- unsigned int i;
- unsigned int quotient;
-
- /* In case the iteration number is higher than the amount saved,
- * the number is run several times in the permutation array */
- quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved;
- loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved;
- for (i = 0; i<=quotient; i++)
- loop_iter = cmd->details.load_array.permutation[loop_iter];
- }
- /* Extracting the data from the loop_indexth indice in save_index
- * array.
- */
- loaded_data =
- &state->cmd[save_index].details.save_array.data_saved[loop_iter];
- data_copy (loaded_data,
- &cmd->exposed);
-}
-
-
-/**
- * Part of the interpreter specific to
- * #PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM
- * Get a random element from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY and exposes it
- */
-static void
-interprete_load_random (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
-{
- struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i];
- unsigned int index;
- int save_index;
-
- save_index = cmd->details.load_random.index_save;
- index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- state->cmd[save_index].details.save_array.
- nb_saved);
- data_copy (&state->cmd[save_index].details.save_array.data_saved[index],
- &cmd->exposed);
-}
-
-
-/**
- * Function called with information about a refresh order.
- *
- * @param cls closure
- * @param rowid unique serial ID for the row in our database
- * @param num_newcoins size of the @a rrcs array
- * @param rrcs array of @a num_newcoins information about coins to be created
- * @param num_tprivs number of entries in @a tprivs, should be #TALER_CNC_KAPPA - 1
- * @param tprivs array of @e num_tprivs transfer private keys
- * @param tp transfer public key information
- */
-static void
-refresh_reveal_cb (void *cls,
- uint32_t num_newcoins,
- const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs,
- unsigned int num_tprivs,
- const struct TALER_TransferPrivateKeyP *tprivs,
- const struct TALER_TransferPublicKeyP *tp)
-{
- /* intentionally empty */
-}
-
-
-/**
- * Iterate over the commands, acting accordingly at each step
- *
- * @param state the current state of the interpreter
- */
-static int
-interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
-{
- for (state->i = 0; PERF_TALER_EXCHANGEDB_CMD_END !=
- state->cmd[state->i].command; state->i++)
- {
- switch (state->cmd[state->i].command)
- {
- case PERF_TALER_EXCHANGEDB_CMD_END:
- return GNUNET_YES;
-
- case PERF_TALER_EXCHANGEDB_CMD_DEBUG:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "%s\n",
- state->cmd[state->i].label);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOOP:
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_END_LOOP:
- interpret_end_loop (state);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_TIME:
- state->cmd[state->i].exposed.data.time =
- GNUNET_new (struct GNUNET_TIME_Absolute);
- *state->cmd[state->i].exposed.data.time =
- GNUNET_TIME_absolute_get ();
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GAUGER:
- {
- unsigned int start_index;
- unsigned int stop_index;
- float ips;
- struct GNUNET_TIME_Absolute start;
- struct GNUNET_TIME_Absolute stop;
- struct GNUNET_TIME_Relative elapsed;
-
- start_index = state->cmd[state->i].details.gauger.index_start;
- stop_index = state->cmd[state->i].details.gauger.index_stop;
- start = *state->cmd[start_index].exposed.data.time;
- stop = *state->cmd[stop_index].exposed.data.time;
- elapsed = GNUNET_TIME_absolute_get_difference (start,
- stop);
- ips = (1.0 * state->cmd[state->i].details.gauger.divide)
- / (elapsed.rel_value_us / 1000000.0);
- GAUGER (state->cmd[state->i].details.gauger.category,
- state->cmd[state->i].details.gauger.description,
- ips,
- state->cmd[state->i].details.gauger.unit);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION:
- state->session = state->plugin->get_session (state->plugin->cls);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
- GNUNET_break (GNUNET_OK ==
- state->plugin->start (state->plugin->cls,
- state->session,
- "perf-interpreter"));
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION:
- GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
- state->plugin->commit (state->plugin->cls,
- state->session));
- break;
- case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION:
- state->plugin->rollback (state->plugin->cls,
- state->session);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY:
- interpret_save_array (state);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY:
- interpret_load_array (state);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM:
- interprete_load_random (state);
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT:
- {
- int coin_index;
- struct TALER_EXCHANGEDB_Deposit *deposit;
-
- coin_index = state->cmd[state->i].details.create_deposit.index_coin;
- deposit = PERF_TALER_EXCHANGEDB_deposit_init (
- state->cmd[coin_index].exposed.data.coin);
- GNUNET_assert (NULL != deposit);
- state->cmd[state->i].exposed.data.deposit = deposit;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT:
- {
- int deposit_index;
- enum GNUNET_DB_QueryStatus qs;
- struct TALER_EXCHANGEDB_Deposit *deposit;
-
- deposit_index =
- state->cmd[state->i].details.insert_deposit.index_deposit;
- deposit = state->cmd[deposit_index].exposed.data.deposit;
- qs = state->plugin->ensure_coin_known (state->plugin->cls,
- state->session,
- &deposit->coin);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- qs = state->plugin->insert_deposit (state->plugin->cls,
- state->session,
- deposit);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- state->cmd[state->i].exposed.data.deposit
- = PERF_TALER_EXCHANGEDB_deposit_copy (deposit);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT:
- {
- unsigned int source_index;
- enum GNUNET_DB_QueryStatus ret;
- struct PERF_TALER_EXCHANGEDB_Data *data;
-
- source_index = state->cmd[state->i].details.get_deposit.index_deposit;
- data = &state->cmd[source_index].exposed;
- ret = state->plugin->have_deposit (state->plugin->cls,
- state->session,
- data->data.deposit,
- GNUNET_YES);
- GNUNET_assert (0 >= ret);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE:
- {
- struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
-
- reserve = PERF_TALER_EXCHANGEDB_reserve_init ();
- state->cmd[state->i].exposed.data.reserve = reserve;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE:
- {
- unsigned int reserve_index;
- int ret;
- struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
- char *sndr;
- uint32_t uid;
- struct GNUNET_TIME_Absolute now;
-
- reserve_index =
- state->cmd[state->i].details.insert_reserve.index_reserve;
- reserve = state->cmd[reserve_index].exposed.data.reserve;
- GNUNET_asprintf (&sndr,
- "payto://x-taler-test/localhost:8080/%u",
- (unsigned int) GNUNET_CRYPTO_random_u32 (
- GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX));
- uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
- ret = state->plugin->reserves_in_insert (state->plugin->cls,
- state->session,
- &reserve->reserve.pub,
- &reserve->reserve.balance,
- now,
- sndr,
- "account-1",
- &uid,
- sizeof (uid));
- GNUNET_assert (GNUNET_SYSERR != ret);
- GNUNET_free (sndr);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE:
- {
- unsigned int reserve_index;
- int ret;
- struct PERF_TALER_EXCHANGEDB_Data *data;
-
-
- reserve_index = state->cmd[state->i].details.get_reserve.index_reserve;
- data = &state->cmd[reserve_index].exposed;
- ret = state->plugin->reserve_get (state->plugin->cls,
- state->session,
- &data->data.reserve->reserve);
- GNUNET_assert (GNUNET_OK == ret);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY:
- {
- unsigned int reserve_index;
- struct TALER_EXCHANGEDB_ReserveHistory *history;
- struct PERF_TALER_EXCHANGEDB_Data *data;
- enum GNUNET_DB_QueryStatus qs;
-
- reserve_index =
- state->cmd[state->i].details.get_reserve_history.index_reserve;
- data = &state->cmd[reserve_index].exposed;
- qs = state->plugin->get_reserve_history (state->plugin->cls,
- state->session,
- &data->data.reserve->reserve.
- pub,
- &history);
- GNUNET_assert (0 >= qs);
- GNUNET_assert (NULL != history);
- state->plugin->free_reserve_history (state->plugin->cls,
- history);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION:
- {
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki =
- PERF_TALER_EXCHANGEDB_denomination_init ();
- GNUNET_assert (NULL != dki);
- state->cmd[state->i].exposed.data.dki = dki;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION:
- {
- unsigned int denom_index;
- enum GNUNET_DB_QueryStatus ret;
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
-
- denom_index =
- state->cmd[state->i].details.insert_denomination.index_denom;
- dki = state->cmd[denom_index].exposed.data.dki;
- ret = state->plugin->insert_denomination_info (state->plugin->cls,
- state->session,
- &dki->denom_pub,
- &dki->issue);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == ret);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION:
- {
- unsigned int denom_index;
- enum GNUNET_DB_QueryStatus qs;
- struct PERF_TALER_EXCHANGEDB_Data *data;
- struct GNUNET_HashCode hc;
-
- denom_index = state->cmd[state->i].details.get_denomination.index_denom;
- data = &state->cmd[denom_index].exposed;
- GNUNET_CRYPTO_rsa_public_key_hash (
- data->data.dki->denom_pub.rsa_public_key,
- &hc);
- qs = state->plugin->get_denomination_info (state->plugin->cls,
- state->session,
- &hc,
- &data->data.dki->issue);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW:
- {
- unsigned int dki_index;
- unsigned int reserve_index;
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
-
- dki_index = state->cmd[state->i].details.create_withdraw.index_dki;
- reserve_index =
- state->cmd[state->i].details.create_withdraw.index_reserve;
- coin = PERF_TALER_EXCHANGEDB_coin_init (
- state->cmd[dki_index].exposed.data.dki,
- state->cmd[reserve_index].
- exposed.data.reserve);
- GNUNET_assert (NULL != coin);
- state->cmd[state->i].exposed.data.coin = coin;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW:
- {
- unsigned int coin_index;
- enum GNUNET_DB_QueryStatus qs;
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
-
- coin_index = state->cmd[state->i].details.insert_withdraw.index_coin;
- coin = state->cmd[coin_index].exposed.data.coin;
- qs = state->plugin->insert_withdraw_info (state->plugin->cls,
- state->session,
- &coin->blind);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW:
- {
- unsigned int source_index;
- enum GNUNET_DB_QueryStatus qs;
- struct PERF_TALER_EXCHANGEDB_Data *data;
-
- source_index =
- state->cmd[state->i].details.get_denomination.index_denom;
- data = &state->cmd[source_index].exposed;
- qs = state->plugin->get_withdraw_info (state->plugin->cls,
- state->session,
- &data->data.coin->blind.
- h_coin_envelope,
- &data->data.coin->blind);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION:
- {
- unsigned int coin_index;
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
- struct TALER_EXCHANGEDB_TransactionList *transactions;
- enum GNUNET_DB_QueryStatus qs;
-
- coin_index =
- state->cmd[state->i].details.get_coin_transaction.index_coin;
- coin = state->cmd[coin_index].exposed.data.coin;
- qs = state->plugin->get_coin_transactions (state->plugin->cls,
- state->session,
- &coin->public_info.coin_pub,
- GNUNET_YES,
- &transactions);
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
- GNUNET_assert (transactions != NULL);
- state->plugin->free_coin_transaction_list (state->plugin->cls,
- transactions);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION:
- {
- struct TALER_EXCHANGEDB_RefreshSession refresh_session;
- unsigned int coin_index;
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
-
- coin_index =
- state->cmd[state->i].details.create_refresh_session.index_coin;
- coin = state->cmd[coin_index].exposed.data.coin;
-
- refresh_session.coin = coin->public_info;
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &refresh_session.coin_sig,
- sizeof (refresh_session.coin_sig));
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
- &refresh_session.rc.session_hash);
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (CURRENCY ":1.1",
- &refresh_session.amount_with_fee));
- refresh_session.noreveal_index = 1;
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
- state->plugin->ensure_coin_known (state->plugin->cls,
- state->session,
- &refresh_session.coin));
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
- state->plugin->insert_melt (state->plugin->cls,
- state->session,
- &refresh_session));
- state->cmd[state->i].exposed.data.rc = refresh_session.rc;
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION:
- {
- unsigned int hash_index;
- const struct TALER_RefreshCommitmentP *rc;
- struct TALER_EXCHANGEDB_RefreshMelt refresh;
-
- hash_index =
- state->cmd[state->i].details.get_refresh_session.index_hash;
- rc = &state->cmd[hash_index].exposed.data.rc;
- state->plugin->get_melt (state->plugin->cls,
- state->session,
- rc,
- &refresh);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL:
- {
- unsigned int hash_index;
- unsigned int denom_index;
- const struct TALER_RefreshCommitmentP *rc;
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *denom;
- struct TALER_TransferPublicKeyP tpub;
- struct TALER_TransferPrivateKeyP tprivs[2];
- struct TALER_EXCHANGEDB_RefreshRevealedCoin rrc;
-
- hash_index =
- state->cmd[state->i].details.insert_refresh_reveal.index_hash;
- denom_index =
- state->cmd[state->i].details.insert_refresh_reveal.index_denom;
- rc = &state->cmd[hash_index].exposed.data.rc;
- denom = state->cmd[denom_index].exposed.data.dki;
- rrc.denom_pub = denom->denom_pub;
- rrc.coin_ev = "coin_ev";
- rrc.coin_ev_size = strlen (rrc.coin_ev) + 1;
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &rrc.coin_sig,
- sizeof (struct TALER_CoinSpendSignatureP));
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- tprivs,
- sizeof (struct TALER_TransferPrivateKeyP)
- * 2);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- &tpub,
- sizeof (struct TALER_TransferPublicKeyP));
- GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
- state->plugin->insert_refresh_reveal (state->plugin->cls,
- state->session,
- rc,
- 1,
- &rrc,
- 2,
- tprivs,
- &tpub));
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL:
- {
- int hash_index;
- const struct TALER_RefreshCommitmentP *rc;
-
- hash_index = state->cmd[state->i].details.get_refresh_reveal.index_hash;
- rc = &state->cmd[hash_index].exposed.data.rc;
- state->plugin->get_refresh_reveal (state->plugin->cls,
- state->session,
- rc,
- &refresh_reveal_cb,
- state);
- }
- break;
-
- case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA:
- break;
-
- }
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Runs the commands given in @a cmd, working with
- * the database referenced by @a db_plugin
- *
- * @param db_plugin the connection to the database
- * @param cmd the commands to run
- */
-int
-PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
- struct PERF_TALER_EXCHANGEDB_Cmd cmd[])
-{
- int ret;
- struct PERF_TALER_EXCHANGEDB_interpreter_state state =
- {.i = 0, .cmd = cmd, .plugin = db_plugin};
-
- ret = cmd_init (cmd);
- if (GNUNET_SYSERR == ret)
- return ret;
- state.session = db_plugin->get_session (db_plugin->cls);
- if (NULL == state.session)
- {
- cmd_clean (cmd);
- return GNUNET_SYSERR;
- }
- GNUNET_assert (NULL != state.session);
- ret = interpret (&state);
- cmd_clean (cmd);
- return ret;
-}
-
-
-/**
- * Initialize the database and run the benchmark
- *
- * @param benchmark_name the name of the benchmark, displayed in the logs
- * @param configuration_file path to the taler configuration file to use
- * @param init the commands to use for the database initialisation,
- * if #NULL the standard initialization is used
- * @param benchmark the commands for the benchmark
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure, #GNUNET_NO
- * if we failed to init the database
- */
-int
-PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
- const char *configuration_file,
- struct PERF_TALER_EXCHANGEDB_Cmd *init,
- struct PERF_TALER_EXCHANGEDB_Cmd *benchmark)
-{
- struct TALER_EXCHANGEDB_Plugin *plugin;
- struct GNUNET_CONFIGURATION_Handle *config;
- int ret = 0;
- struct PERF_TALER_EXCHANGEDB_Cmd init_def[] = {
- // Denomination used to create coins
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop",
- PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert",
- "01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
- "01 - denomination loop",
- "01 - denomination",
- PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "01 - denomination loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
- // End of initialization
- // Reserve initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop",
- PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert",
- "02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
- "02 - init reserve loop",
- "02 - reserve",
- PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "02 - init reserve loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
- // End reserve init
- // Withdrawal initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop",
- PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
- "03 - init withdraw loop",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
- "03 - init withdraw loop",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw",
- "03 - denomination load",
- "03 - reserve load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert",
- "03 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin",
- "03 - init withdraw loop",
- "03 - withdraw",
- PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("",
- "03 - init withdraw loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
- // End of withdrawal initialization
- // Deposit initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop",
- PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - denomination load",
- "04 - deposit init loop",
- "03 - save coin"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
- "04 - denomination load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
- "04 - commit transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
- "04 - deposit init loop",
- "04 - deposit",
- PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
- "04 - deposit init loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
- // End of deposit initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end")
- };
-
- GNUNET_log_setup (benchmark_name,
- "INFO",
- NULL);
- config = GNUNET_CONFIGURATION_create ();
- ret = GNUNET_CONFIGURATION_parse (config,
- configuration_file);
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error parsing configuration file\n");
- return GNUNET_SYSERR;
- }
- plugin = TALER_EXCHANGEDB_plugin_load (config);
- if (NULL == plugin)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error connectiong to the database\n");
- return GNUNET_NO;
- }
- ret = plugin->create_tables (plugin->cls);
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error while creating the database architecture\n");
- return GNUNET_NO;
- }
- /*
- * Running the initialization
- */
- if (NULL == init)
- {
- init = init_def;
- }
- ret = PERF_TALER_EXCHANGEDB_interpret (plugin,
- init);
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error during database initialization\n");
- return ret;
- }
- /*
- * Running the benchmark
- */
- ret = PERF_TALER_EXCHANGEDB_interpret (plugin,
- benchmark);
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error while runing the benchmark\n");
- return ret;
- }
- /* Drop tables */
- {
- ret = plugin->drop_tables (plugin->cls);
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error cleaning the database\n");
- return ret;
- }
- }
- TALER_EXCHANGEDB_plugin_unload (plugin);
- GNUNET_CONFIGURATION_destroy (config);
- return ret;
-}
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.h b/src/exchangedb/perf_taler_exchangedb_interpreter.h
deleted file mode 100644
index 414e33fe..00000000
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.h
+++ /dev/null
@@ -1,1145 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file exchangedb/perf_taler_exchangedb_interpreter.h
- * @brief Library for performance analysis of the Taler database
- * @author Nicolas Fournier
- *
- * This library contains functions and macro alowing Taler performance analysis
- * to be written with ease.
- * To do so, create a #PERF_TALER_EXCHANGEDB_Cmd array and fill it with the commands
- * to execute in chronological order. Some command have an exposed variable wich
- * can be reused in other commands.
- * Macros are available to make the use much easier so feel free to use them
- * to initialize your own command array.
- */
-
-#ifndef __PERF_TALER_EXCHANGEDB_INTERPRETER_H__
-#define __PERF_TALER_EXCHANGEDB_INTERPRETER_H__
-
-#include <sys/time.h>
-#include "taler_exchangedb_plugin.h"
-
-
-#define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT 10
-#define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE 10
-
-#define PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT 100
-#define PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE 10
-
-#define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT 100
-#define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE 10
-
-#define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT 100
-#define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE 10
-
-
-/**
- * Marks the end of the command chain
- *
- * @param _label The label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_END(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_END, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
- }
-
-
-/**
- * Prints @ _label to stdout
- *
- * @param _label The label of the command,
- * will be logged each time the command runs
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_DEBUG, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
- }
-
-/**
- * The begining of a loop
- *
- * @param _label the label of the loop
- * @param _iter the number of iterations of the loop
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP(_label, _iter) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_LOOP, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.loop = { \
- .max_iterations = _iter, \
- .curr_iteration = 0 } \
- }
-
-/**
- * Marks the end of the loop @_label_loop
- *
- * @param _label the label of the command
- * @param _label_loop the label of the loop closed by this command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP(_label, _label_loop) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_END_LOOP, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.end_loop.label_loop = _label_loop \
- }
-
-/**
- * Saves the time of execution to use for logging with Gauger
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_TIME, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_TIME \
- }
-
-/**
- * Commits the duration between @a _label_start and @a _label_stop
- * to Gauger with @a _description explaining what was measured.
- *
- * @param _label the label of this command
- * @param _label_start label of the start of the measurment
- * @param _label_stop label of the end of the measurment
- * @param _description description of the measure displayed in Gauger
- * @param _unit the unit of the data measured, typicly something/sec
- * @param _divide number of measurments in the interval
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, \
- _category, _description, _unit, \
- _divide) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GAUGER, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.gauger = { \
- .label_start = _label_start, \
- .label_stop = _label_stop, \
- .category = _category, \
- .description = _description, \
- .unit = _unit, \
- .divide = _divide, \
- } \
- }
-
-/**
- * Initiate a database transaction
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- }
-
-/**
- * Commits a database transaction
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- }
-
-/**
- * Abort the current transaction
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_ABORT_TRANSACTION(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, \
- .label = _label,
-
-/**
- * Saves randomly selected items from @a _label_save
- * Saved items can latter be access using #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY
- *
- * @param _label the label of the command, used by other commands to reference it
- * @param _label_loop the label of the loop the array iterates over
- * @param _label_save the label of the command which outout is saved by this command
- * @param _nb_saved the total number of items to be saved
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, \
- _label_save, _nb_saved) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.save_array = { \
- .label_loop = _label_loop, \
- .label_save = _label_save, \
- .nb_saved = _nb_saved, \
- } \
- }
-
-/**
- * Loads data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY to allow other
- * commands to access it
- *
- * @param _label the label of this command, referenced by commands to access it's outpout
- * @param _label_loop the label of the loop to iterate over
- * @param _label_save the label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY providing data
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, \
- _label_save) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.load_array = { \
- .label_loop = _label_loop, \
- .label_save = _label_save \
- } \
- }
-
-/**
- * Create a denomination key to use
- * Exposes a #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO to be used by other commands
- * @exposed #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO
- *
- * @param _label the label of this command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, \
- }
-
-/**
- * Inserts informations about a denomination key in the database
- *
- * @param _label the label of this command
- * @param _label_denom the label of the denomination to insert
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION(_label, _label_denom) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.insert_denomination.label_denom = _label_denom, \
- }
-
-/**
- * Polls the database about informations regarding a specific denomination key
- *
- * @param _label the label of this command
- * @param _label_denom the label of the command providing information about the denomination key
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION(_label, _label_denom) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_denomination.label_denom = _label_denom \
- }
-
-/**
- * Create a reserve to be used later
- * Exposes a #PERF_TALER_EXCHANGEDB_RESERVE
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE(_label) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_RESERVE \
- }
-
-/**
- * Insert a new reserve in the database containing 1000 Euros
- *
- * @param _label the name of this command
- * @param _label_reserve the label of the reserve to insert
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE(_label, _label_reserve) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.insert_reserve.label_reserve = _label_reserve \
- }
-
-/**
- * Polls the database for a secific reserve's details
- *
- * @param _label the label of this command
- * @param _label_reserve the reserve to poll
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE(_label, _label_reserve) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_reserve.label_reserve = _label_reserve \
- }
-
-/**
- * Polls the database for the history of a reserve
- *
- * @param _label the label of the command
- * @param _label_reserve the reserve to examine
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label, \
- _label_reserve) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_reserve_history.label_reserve = _label_reserve \
- }
-
-/**
- * Creates a coin to be used later
- *
- * @param _label the label of this command
- * @param _label_dki denomination key used to sign the coin
- * @param _label_reserve reserve used to emmit the coin
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW(_label, _label_dki, \
- _label_reserve) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_COIN, \
- .details.create_withdraw = { \
- .label_dki = _label_dki, \
- .label_reserve = _label_reserve, \
- } \
- }
-
-/**
- * Inserts information about a withdrawal into the database
- *
- * @exposes #PERF_TALER_EXCHANGEDB_COIN
- *
- * @param _label the label of this command
- * @param _label_coin the coin to insert
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_coin) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.insert_withdraw.label_coin = _label_coin \
- }
-
-
-/**
- * Polls the database about informations regarding a specific withdrawal
- *
- * @param _label the label of this command
- * @param _label_coin the coin to check
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW(_label, _label_coin) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_withdraw.label_coin = _label_coin, \
- }
-
-
-/**
- * The /reserve/withdraw api call
- *
- * Exposes #PERF_TALER_EXCHANGEDB_COIN
- *
- * @param _label the label of this command
- * @param _label_dki the denomination of the created coin
- * @param _label_reserve the reserve used to provide currency
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, \
- _label_reserve) \
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW (_label "withdraw", \
- _label_dki, \
- _label_reserve), \
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION (_label "withdraw info", \
- _label_dki), \
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY (_label "reserve_history", \
- _label_reserve), \
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW (_label "insert withdraw", \
- _label "withdraw")
-
-/**
- * Create a deposit for use later
- * @exposes #PERF_TALER_EXCHANGEDB_DEPOSIT
- *
- * @param _label the label of this command
- * @param _label_coin the coin used to pay
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT(_label, _label_coin) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_DEPOSIT, \
- .details.create_deposit.label_coin = _label_coin, \
- }
-
-/**
- * Insert a deposit into the database
- *
- * @param _label the label of this command
- * @param _label_deposit the deposit inseerted
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_deposit) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.insert_deposit.label_deposit = _label_deposit, \
- }
-
-/**
- * Check if a deposit is in the database
- *
- * @param _label the label of this command
- * @param _label_deposit the deposit to use
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_deposit.label_deposit = _label_deposit \
- }
-
-/**
- * Access the transaction history of a coin
- *
- * @param _label the label of the command
- * @param _label_coin the coin which history is checked
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION(_label, _label_coin) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \
- .details.get_coin_transaction.label_coin = _label_coin \
- }
-
-/**
- * The /deposit api call
- *
- * @param _label the label of the command
- * @param _label_coin the coin used for the deposit
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT(_label, _label_coin) \
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION (_label "coin history", \
- _label_coin), \
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT (_label "deposit", \
- _label_coin), \
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT (_label "insert", \
- _label "deposit")
-
-/**
- * Insert informations about a refresh session
- * melts one coin into another
- *
- * @param _label the label of the command
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION(_label, \
- _label_coin) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, \
- .label = _label, \
- .details.create_refresh_session.label_coin = _label_coin, \
- .exposed.type = PERF_TALER_EXCHANGEDB_REFRESH_HASH \
- }
-
-/**
- * Get informations about a refresh session
- *
- * @param _label the label of the command
- * @param _label_hash the label of the hash to search
- */
-#define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_REFRESH_SESSION(_label, \
- _label_hash) \
- { \
- .command = PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, \
- .label = _label, \
- .exposed.type = PERF_TALER_EXCHANGEDB_NONE \
- }
-
-
-/**
- * The type of data stored in #PERF_TALER_EXCHANGEDB_Memory
- */
-enum PERF_TALER_EXCHANGEDB_Type
-{
- PERF_TALER_EXCHANGEDB_NONE,
- PERF_TALER_EXCHANGEDB_TIME,
- PERF_TALER_EXCHANGEDB_DENOMINATION_INFO,
- PERF_TALER_EXCHANGEDB_RESERVE,
- PERF_TALER_EXCHANGEDB_COIN,
- PERF_TALER_EXCHANGEDB_DEPOSIT,
- PERF_TALER_EXCHANGEDB_REFRESH_HASH
-};
-
-
-/**
- * Structure used to handle several data type
- */
-struct PERF_TALER_EXCHANGEDB_Data
-{
- enum PERF_TALER_EXCHANGEDB_Type type;
-
- /**
- * Storage for a variety of data type
- * The data saved should match #type
- */
- union PERF_TALER_EXCHANGEDB_Memory
- {
- /** #PERF_TALER_EXCHANGEDB_TIME */
- struct GNUNET_TIME_Absolute *time;
- /** #PERF_TALER_EXCHANGEDB_DEPOSIT */
- struct TALER_EXCHANGEDB_Deposit *deposit;
- /** #PERF_TALER_EXCHANGEDB_COIN */
- struct PERF_TALER_EXCHANGEDB_Coin *coin;
- /** #PERF_TALER_EXCHANGEDB_RESERVE */
- struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
- /** #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO */
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
- /** #PERF_TALER_EXCHANGEDB_REFRESH_HASH */
- struct TALER_RefreshCommitmentP rc;
- } data;
-};
-
-
-/**
- * Name of the command
- */
-enum PERF_TALER_EXCHANGEDB_CMD_Name
-{
- /**
- * All comand chain must hace this as their last command
- */
- PERF_TALER_EXCHANGEDB_CMD_END,
-
- /**
- * Prints it's label
- */
- PERF_TALER_EXCHANGEDB_CMD_DEBUG,
-
- /**
- * Define the start of al command chain loop
- */
- PERF_TALER_EXCHANGEDB_CMD_LOOP,
-
- /**
- * Define the end of a command chain loop
- */
- PERF_TALER_EXCHANGEDB_CMD_END_LOOP,
-
- /**
- * Save the time at which the command was executed
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_TIME,
-
- /**
- * Upload performance to Gauger
- */
- PERF_TALER_EXCHANGEDB_CMD_GAUGER,
-
- /**
- * Start a new session
- */
- PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION,
-
- /**
- * Start a database transaction
- */
- PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION,
-
- /**
- * End a database transaction
- */
- PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION,
-
- /**
- * Abort a transaction started with #PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION
- */
- PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION,
-
- /**
- * Saves random deposits from a loop
- */
- PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY,
-
- /**
- * Load items saved earlier in a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY
- * The items are loaded in a random order, but all of them will be loaded
- */
- PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY,
-
- /**
- * Loads a random item from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY
- * A random item is loaded each time the command is run
- */
- PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM,
-
- /**
- * Create a denomination to be used later
- */
- PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION,
-
- /**
- * Insert informations about a denomination key in the database
- */
- PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION,
-
- /**
- * Polls the database for informations about a specific denomination key
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION,
-
- /**
- * Create a reserve to be used later
- */
- PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE,
-
- /**
- * Insert currency in a reserve / Create a reserve
- */
- PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE,
-
- /**
- * Get Informations about a reserve
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE,
-
- /**
- * Get the history of a reserve
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY,
-
- /**
- * Create a withdrawal to be used later
- */
- PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW,
-
- /**
- * Insert informations about a withdrawal in the database
- */
- PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW,
-
- /**
- * Pulls informations about a withdrawal from the database
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW,
-
- /**
- * Get the list of all transactions the coin has been in
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION,
-
- /**
- * Create a deposit to be used later
- */
- PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT,
-
- /**
- * Insert a deposit into the database
- */
- PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT,
-
- /**
- * Check if a deposit is in the database
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT,
-
- /**
- * Create a refresh session
- * The number of melted coins is 1,
- * The number of exchangeed coins is 1
- */
- PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION,
-
- /**
- * Get a refresh session informations
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION,
-
- /**
- * Insert a melt refresh reveal data
- */
- PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL,
-
- /**
- * Get informations about a refresh reveal data
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL,
-
- /**
- * Get the link data list of a coin
- */
- PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA
-
-};
-
-
-/**
- * Contains extra data required for any command
- */
-union PERF_TALER_EXCHANGEDB_CMD_Details
-{
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_LOOP command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_loopDetails
- {
- /**
- * Maximum number of iteration in the loop
- */
- const unsigned int max_iterations;
-
- /**
- * The current iteration of the loop
- */
- unsigned int curr_iteration;
- } loop;
-
- /**
- * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_END_LOOP command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_endLoopDetails
- {
- /**
- * Label of the loop closed by the command
- */
- const char *label_loop;
- unsigned int index_loop;
- } end_loop;
-
- /**
- * Details about the #PERF_TALER_EXCHANGEDB_CMD_GAUGER command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_gaugerDetails
- {
- /**
- * Label of the starting timestamp
- */
- const char *label_start;
- unsigned int index_start;
-
- /**
- * Label of the ending timestamp
- */
- const char *label_stop;
- unsigned int index_stop;
-
- /**
- * The category of the measurment
- */
- const char *category;
-
- /**
- * Description of the metric, used in Gauger
- */
- const char *description;
-
- /**
- * The name of the metric beeing used
- */
- const char *unit;
-
- /**
- * Constant the result needs to be divided by
- * to get the result per unit
- */
- float divide;
- } gauger;
-
- /**
- * Contains extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_saveArrayDetails
- {
- /**
- * Number of items to save
- */
- unsigned int nb_saved;
-
- /**
- * Number of items already saved
- */
- unsigned int index;
-
- /**
- * Label of the loop it is attached to
- */
- const char *label_loop;
- unsigned int index_loop;
-
- /**
- * Label of the command exposing the item
- */
- const char *label_save;
- unsigned int index_save;
-
- /**
- * Array of data saved
- */
- struct PERF_TALER_EXCHANGEDB_Data *data_saved;
-
- /**
- * Type of the data that will be stored in @a data_saved, for
- * 'static' type checking.
- */
- enum PERF_TALER_EXCHANGEDB_Type type_saved;
-
- } save_array;
-
- /**
- * Extra data required for the #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_loadArrayDetails
- {
- /**
- * The loop in which the command is located
- */
- const char *label_loop;
- unsigned int index_loop;
-
- /**
- * Label of the command where the items were saved
- */
- const char *label_save;
- unsigned int index_save;
-
- /**
- * A permutation array used to randomize the order the items are loaded in
- */
- unsigned int *permutation;
- } load_array;
-
- /**
- * Contains data for the #PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_loadRandomDetails
- {
- /**
- * The label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY the items will be extracted from
- */
- const char *label_save;
- unsigned int index_save;
- } load_random;
-
- /**
- * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_insertDenominationDetails
- {
- /**
- * The label of the source of the denomination to insert
- */
- const char *label_denom;
- unsigned int index_denom;
- } insert_denomination;
-
- /**
- * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getDenominationDetails
- {
- /**
- * The label of the source of the denomination to check
- */
- const char *label_denom;
- unsigned int index_denom;
- } get_denomination;
-
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_insertReserveDetails
- {
- /**
- * The label of the source of the reserve to insert
- */
- const char *label_reserve;
- unsigned int index_reserve;
- } insert_reserve;
-
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getReserveDetails
- {
- /**
- * The label of the source of the reserve to check
- */
- const char *label_reserve;
- unsigned int index_reserve;
- } get_reserve;
-
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getReserveHistoryDetails
- {
- /**
- * The label of the source of the reserve to check
- */
- const char *label_reserve;
- unsigned int index_reserve;
- } get_reserve_history;
-
- /**
- * Extra data related to the #PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_createWithdrawDetails
- {
- /**
- * label of the denomination key used to sign the coin
- */
- const char *label_dki;
- unsigned int index_dki;
-
- /**
- * label of the reserve the money to exchange the coin comes from
- */
- const char *label_reserve;
- unsigned int index_reserve;
- } create_withdraw;
-
- /**
- * data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW
- */
- struct PERF_TALER_EXCHANGEDB_CMD_insertWithdrawDetails
- {
- /**
- * label of the source for the coin information
- */
- const char *label_coin;
- unsigned int index_coin;
- } insert_withdraw;
-
- /**
- * data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getWithdraw
- {
- /**
- * label of the source for the coin information
- */
- const char *label_coin;
- unsigned int index_coin;
- } get_withdraw;
-
- /**
- * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getCoinTransactionDetails
- {
- /**
- * The coin which history is checked
- */
- const char *label_coin;
- unsigned int index_coin;
- } get_coin_transaction;
-
- /**
- * Data used by the #PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_createDepositDetails
- {
- /**
- * Label of the source where the reserve used to create the coin is
- */
- const char *label_coin;
- unsigned int index_coin;
- } create_deposit;
-
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_insertDepositDetails
- {
- /**
- * The label of the source of the deposit to check
- */
- const char *label_deposit;
- unsigned int index_deposit;
- } insert_deposit;
-
- /**
- * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getDepositDetails
- {
- /**
- * The label of the source of the deposit to check
- */
- const char *label_deposit;
- unsigned int index_deposit;
- } get_deposit;
-
- /**
- * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_createRefreshSessionDetails
- {
- /**
- * label of the source of the hash of the session
- */
- const char *label_coin;
- unsigned int index_coin;
- } create_refresh_session;
-
- /**
- * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getRefreshSessionDetails
- {
- /**
- * label of the source of the hash of the session
- */
- const char *label_hash;
- unsigned int index_hash;
- } get_refresh_session;
-
- /**
- * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_insertRefreshRevealDetails
- {
- /**
- * The refresh session hash
- */
- const char *label_hash;
- unsigned int index_hash;
-
- /**
- * The new coin denomination
- */
- const char *label_denom;
- unsigned int index_denom;
- } insert_refresh_reveal;
-
- /**
- * Data requiered for the #PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getRefreshRevealDetails
- {
- /**
- * The session hash
- */
- const char *label_hash;
- unsigned int index_hash;
-
- } get_refresh_reveal;
-
- /**
- * Data requiered by the #PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA_LIST command
- */
- struct PERF_TALER_EXCHANGEDB_CMD_getLinkDataListDetails
- {
- /**
- * The refresh session hash
- */
- const char *label_hash;
- unsigned int index_hash;
- } get_link_data_list;
-
-
-};
-
-
-/**
- * Command to be interpreted.
- */
-struct PERF_TALER_EXCHANGEDB_Cmd
-{
- /**
- * Type of the command
- */
- enum PERF_TALER_EXCHANGEDB_CMD_Name command;
-
- /**
- * Label to refer to the command
- */
- const char *label;
-
- /**
- * Command specific data
- */
- union PERF_TALER_EXCHANGEDB_CMD_Details details;
-
- /**
- * Data easily accessible
- */
- struct PERF_TALER_EXCHANGEDB_Data exposed;
-};
-
-
-/**
- * Run a benchmark
- *
- * @param benchmark_name the name of the benchmark, displayed in the logs
- * @param configuration_file path to the taler configuration file to use
- * @param init the commands to use for the database initialisation,
- * if #NULL the standard initialization is used
- * @param benchmark the commands for the benchmark
- * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure,
- * #GNUNET_NO if we failed to init the database
- */
-int
-PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name,
- const char *configuration_file,
- struct PERF_TALER_EXCHANGEDB_Cmd *init,
- struct PERF_TALER_EXCHANGEDB_Cmd *benchmark);
-
-
-/**
- * Runs the command array @a cmd
- * using @a db_plugin to connect to the database
- *
- * @param db_plugin the connection to the database
- * @param cmd the commands to run
- */
-int
-PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin,
- struct PERF_TALER_EXCHANGEDB_Cmd cmd[]);
-
-
-/**
- * Check if the given command array is syntaxicly correct
- * This will check if the label are corrects but will not check if
- * they are pointing to an apropriate command.
- *
- * @param cmd the command array to check
- * @return #GNUNET_OK is @a cmd is correct; #GNUNET_SYSERR if it is'nt
- */
-int
-PERF_TALER_EXCHANGEDB_check (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd);
-
-#endif
diff --git a/src/exchangedb/perf_taler_exchangedb_values.h b/src/exchangedb/perf_taler_exchangedb_values.h
deleted file mode 100644
index c158fd9c..00000000
--- a/src/exchangedb/perf_taler_exchangedb_values.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/perf_taler_exchangedb_values.h
- * @brief Values for tweaking the performance analysis
- * @author Nicolas Fournier
- */
-#ifndef __PERF_TALER_EXCHANGEDB__VALUES_H__
-#define __PERF_TALER_EXCHANGEDB__VALUES_H__
-
-
-#endif
diff --git a/src/exchangedb/test_perf_taler_exchangedb.c b/src/exchangedb/test_perf_taler_exchangedb.c
deleted file mode 100644
index ad8e630d..00000000
--- a/src/exchangedb/test_perf_taler_exchangedb.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014, 2015 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file exchangedb/test_perf_taler_exchangedb.c
- * @brief Exchange database performance analysis
- * @author Nicolas Fournier
- */
-#include "platform.h"
-#include "perf_taler_exchangedb_interpreter.h"
-#include "perf_taler_exchangedb_init.h"
-
-
-#define NB_DENOMINATION_INIT 2
-#define NB_DENOMINATION_SAVE 2
-
-#define NB_RESERVE_INIT 4
-#define NB_RESERVE_SAVE 1
-
-#define NB_DEPOSIT_INIT 1
-#define NB_DEPOSIT_SAVE 1
-
-#define NB_WITHDRAW_INIT 1
-#define NB_WITHDRAW_SAVE 1
-
-
-/**
- * Allocate, copies and free all the data used in the interpreter
- * Used to check for memory leaks
- */
-static void
-test_allocate ()
-{
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
- struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki_copy;
- struct PERF_TALER_EXCHANGEDB_Reserve *reserve, *reserve_copy;
- struct PERF_TALER_EXCHANGEDB_Coin *coin, *coin_copy;
- struct TALER_EXCHANGEDB_Deposit *deposit, *deposit_copy;
-
- dki = PERF_TALER_EXCHANGEDB_denomination_init ();
- reserve = PERF_TALER_EXCHANGEDB_reserve_init ();
- coin = PERF_TALER_EXCHANGEDB_coin_init (dki,
- reserve);
- deposit = PERF_TALER_EXCHANGEDB_deposit_init (coin);
-
- dki_copy = PERF_TALER_EXCHANGEDB_denomination_copy (dki);
- reserve_copy = PERF_TALER_EXCHANGEDB_reserve_copy (reserve);
- coin_copy = PERF_TALER_EXCHANGEDB_coin_copy (coin);
- deposit_copy = PERF_TALER_EXCHANGEDB_deposit_copy (deposit);
-
- PERF_TALER_EXCHANGEDB_denomination_free (dki);
- PERF_TALER_EXCHANGEDB_denomination_free (dki_copy);
- PERF_TALER_EXCHANGEDB_reserve_free (reserve);
- PERF_TALER_EXCHANGEDB_reserve_free (reserve_copy);
- PERF_TALER_EXCHANGEDB_coin_free (coin);
- PERF_TALER_EXCHANGEDB_coin_free (coin_copy);
- PERF_TALER_EXCHANGEDB_deposit_free (deposit);
- PERF_TALER_EXCHANGEDB_deposit_free (deposit_copy);
-}
-
-
-/**
- * Runs the performances tests for the exchange database
- * and logs the results using Gauger
- */
-int
-main (int argc, char **argv)
-{
- int ret = 0;
- struct PERF_TALER_EXCHANGEDB_Cmd init[] = {
- PERF_TALER_EXCHANGEDB_INIT_CMD_END ("init")
- };
- struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = {
- // Denomination used to create coins
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop",
- NB_DENOMINATION_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert",
- "01 - denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
- "01 - commit transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
- "01 - denomination loop",
- "01 - denomination",
- NB_DENOMINATION_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
- "01 - denomination loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
- // End of initialization
- // Reserve initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop",
- NB_RESERVE_INIT),
-
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert",
- "02 - reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
- "02 - init reserve loop",
- "02 - reserve",
- NB_RESERVE_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
- "02 - init reserve loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
- // End reserve init
- // Withdrawal initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop",
- NB_WITHDRAW_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
- "03 - init withdraw loop",
- "01 - save denomination"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
- "03 - init withdraw loop",
- "02 - save reserve"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw",
- "03 - denomination load",
- "03 - reserve load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert withdraw",
- "03 - withdraw"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
- "03 - commit transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - coin array",
- "03 - init withdraw loop",
- "03 - withdraw",
- NB_WITHDRAW_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
- "03 - init withdraw loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
- // End of withdrawal initialization
- // Deposit initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time start"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop",
- NB_DEPOSIT_INIT),
- PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load",
- "04 - deposit init loop",
- "03 - coin array"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit",
- "04 - coin load"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert deposit",
- "04 - deposit"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (
- "04 - commit transaction"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
- "04 - deposit init loop",
- "04 - deposit",
- NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
- "04 - deposit init loop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("04 - time stop"),
- PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("04 - gauger",
- "04 - time start",
- "04 - time stop",
- "TEST",
- "time to insert a deposit",
- "deposit/sec",
- NB_DEPOSIT_SAVE),
- PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
- // End of deposit initialization
- PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end"),
- };
-
- test_allocate ();
- ret = PERF_TALER_EXCHANGEDB_run_benchmark ("test-perf-taler-exchangedb",
- "./test-exchange-db-postgres.conf",
- init,
- benchmark);
- if (GNUNET_SYSERR == ret)
- return 1;
- if (GNUNET_NO == ret)
- return 77; /* testcase skipped */
- return 0;
-}