aboutsummaryrefslogtreecommitdiff
path: root/src/mintdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/mintdb')
-rw-r--r--src/mintdb/Makefile.am6
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c51
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h94
3 files changed, 118 insertions, 33 deletions
diff --git a/src/mintdb/Makefile.am b/src/mintdb/Makefile.am
index 544519011..82722bd54 100644
--- a/src/mintdb/Makefile.am
+++ b/src/mintdb/Makefile.am
@@ -50,7 +50,7 @@ check_PROGRAMS = \
test-mintdb-keyio \
test-mintdb-postgres \
test-perf-taler-mintdb \
- perf-taler-mintdb
+ perf-mintdb
TESTS = \
test-mintdb-postgres \
@@ -93,11 +93,11 @@ test_perf_taler_mintdb_LDADD = \
-ljansson \
-lgnunetutil
-perf_taler_mintdb_SOURCES = \
+perf_mintdb_SOURCES = \
perf_taler_mintdb.c \
perf_taler_mintdb_init.c \
perf_taler_mintdb_interpreter.c
-perf_taler_mintdb_LDADD = \
+perf_mintdb_LDADD = \
libtalermintdb.la \
$(top_srcdir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index db40a15fd..8df3cf747 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf_taler_mintdb_interpreter.c
@@ -510,7 +510,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
GNUNET_assert (GNUNET_SYSERR !=
(source_index = cmd_find (state->cmd,
state->cmd[state->i]
- .details.get_deposit.label_source)));
+ .details.get_deposit.label_deposit)));
GNUNET_assert (NULL !=
(deposit = state->cmd[source_index].exposed.data.deposit));
state->plugin->have_deposit (state->plugin->cls,
@@ -544,15 +544,15 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
{
- int source_index;
+ int reserve_index;
struct TALER_MINTDB_Reserve *reserve;
GNUNET_assert (GNUNET_SYSERR !=
- (source_index = cmd_find (state->cmd,
+ (reserve_index = cmd_find (state->cmd,
state->cmd[state->i]
- .details.get_reserve.label_source)));
+ .details.get_reserve.label_reserve)));
GNUNET_assert (NULL !=
- (reserve = state->cmd[source_index].exposed.data.reserve));
+ (reserve = state->cmd[reserve_index].exposed.data.reserve));
GNUNET_assert (GNUNET_OK ==
(state->plugin->reserve_get (state->plugin->cls,
state->session,
@@ -560,6 +560,27 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
}
break;
+ case PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY:
+ {
+ int reserve_index;
+ struct TALER_MINTDB_ReserveHistory *history;
+ struct TALER_MINTDB_Reserve *reserve;
+
+ GNUNET_assert (GNUNET_SYSERR !=
+ (reserve_index = cmd_find (state->cmd,
+ state->cmd[state->i]
+ .details.get_reserve_history.label_reserve)));
+ GNUNET_assert (NULL !=
+ (reserve = state->cmd[reserve_index].exposed.data.reserve));
+ GNUNET_assert (NULL !=
+ (history = state->plugin->get_reserve_history (state->plugin->cls,
+ state->session,
+ &reserve->pub)));
+ state->plugin->free_reserve_history (state->plugin->cls,
+ history);
+ }
+ break;
+
case PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION:
{
struct TALER_MINTDB_DenominationKeyIssueInformation *dki =
@@ -581,7 +602,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
GNUNET_assert (GNUNET_SYSERR !=
(source_index = cmd_find (state->cmd,
state->cmd[state->i]
- .details.get_denomination.label_source)));
+ .details.get_denomination.label_denom)));
GNUNET_assert (NULL !=
(dki = state->cmd[source_index].exposed.data.dki));
state->plugin->get_denomination_info (state->plugin->cls,
@@ -625,7 +646,7 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
GNUNET_assert (GNUNET_SYSERR !=
(source_index = cmd_find (state->cmd,
state->cmd[state->i]
- .details.get_denomination.label_source)));
+ .details.get_denomination.label_denom)));
GNUNET_assert (NULL !=
(blindcoin = state->cmd[source_index].exposed.data.blindcoin));
state->plugin->get_withdraw_info (state->plugin->cls,
@@ -927,16 +948,16 @@ PERF_TALER_MINTDB_check (const struct PERF_TALER_MINTDB_Cmd *cmd)
case PERF_TALER_MINTDB_CMD_GET_DENOMINATION:
ret_loc = find_test (cmd,
- cmd[i].details.get_denomination.label_source,
+ cmd[i].details.get_denomination.label_denom,
i,
- "label_source");
+ "label_denom");
break;
case PERF_TALER_MINTDB_CMD_GET_RESERVE:
ret_loc = find_test (cmd,
- cmd[i].details.get_reserve.label_source,
+ cmd[i].details.get_reserve.label_reserve,
i,
- "label_source");
+ "label_reserve");
break;
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
@@ -948,9 +969,9 @@ PERF_TALER_MINTDB_check (const struct PERF_TALER_MINTDB_Cmd *cmd)
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
ret_loc = find_test (cmd,
- cmd[i].details.get_deposit.label_source,
+ cmd[i].details.get_deposit.label_deposit,
i,
- "label_source");
+ "label_deposit");
break;
case PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW:
@@ -962,9 +983,9 @@ PERF_TALER_MINTDB_check (const struct PERF_TALER_MINTDB_Cmd *cmd)
case PERF_TALER_MINTDB_CMD_GET_WITHDRAW:
ret_loc = find_test (cmd,
- cmd[i].details.get_withdraw.label_source,
+ cmd[i].details.get_withdraw.label_coin,
i,
- "label_source");
+ "label_coin");
break;
default :
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h
index 1cb9cfdee..00c03b5e1 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf_taler_mintdb_interpreter.h
@@ -17,6 +17,14 @@
* @file mintdb/perf_taler_mintdb_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_MINTDB_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_MINTDB_INTERPRETER_H__
@@ -209,6 +217,8 @@
/**
* Inserts informations about a denomination key in the database
*
+ * @exposed #PERF_TALER_MINTDB_DENOMINATION_INFO
+ *
* @param _label the label of this command
*/
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
@@ -222,19 +232,21 @@
* Polls the database about informations regarding a specific denomination key
*
* @param _label the label of this command
- * @param _label_source the label of the command prividing information about the denomination key
+ * @param _label_denom the label of the command prividing information about the denomination key
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_denom) \
{ \
.command = PERF_TALER_MINTDB_CMD_GET_DENOMINATION, \
.label = _label, \
.exposed.type = PERF_TALER_MINTDB_NONE, \
- .details.get_denomination.label_source = _label_source, \
+ .details.get_denomination.label_denom = _label_denom, \
}
/**
* Creates a new reserve in the database
*
+ * @exposed #PERF_TALER_MINTDB_RESERVE
+ *
* @param _label the name of this command
*/
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE(_label) \
@@ -249,20 +261,37 @@
* Polls the database for a secific reserve's details
*
* @param _label the label of this command
- * @param _label_source Source for the reserve to poll
+ * @param _label_reserve Source for the reserve to poll
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_source) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_reserve) \
{ \
.command = PERF_TALER_MINTDB_CMD_GET_RESERVE, \
.label = _label, \
.exposed.type = PERF_TALER_MINTDB_NONE, \
- .details.get_reserve.label_source = _label_source \
+ .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_MINTDB_INIT_CMD_GET_RESERVE_HISTORY(_label, _label_reserve) \
+{ \
+ .command = PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY, \
+ .label = _label, \
+ .exposed.type = PERF_TALER_MINTDB_NONE, \
+ .details.get_reserve_history.label_reserve = _label_reserve \
}
/**
* Insert a deposit into the database
*
+ * @exposes #PERF_TALER_MINTDB_DEPOSIT
+ *
* @param _label the label of this command
* @param _label_dki source to use for the denomination key
*/
@@ -286,13 +315,15 @@
.command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
.label = _label, \
.exposed.type = PERF_TALER_MINTDB_NONE, \
- .details.get_deposit.label_source = _label_deposit \
+ .details.get_deposit.label_deposit = _label_deposit \
}
/**
* Inserts informations about a withdrawal in the database
*
+ * @exposes #PERF_TALER_MINTDB_BLINDCOIN
+ *
* @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
@@ -313,18 +344,34 @@
* Polls the database about informations regarding a specific withdrawal
*
* @param _label the label of this command
- * @param _label_source the label of the command providing the coin to check
+ * @param _label_coin the label of the command providing the coin to check
*/
-#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
+#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_coin) \
{ \
.command = PERF_TALER_MINTDB_CMD_GET_WITHDRAW, \
.label = _label, \
.exposed.type = PERF_TALER_MINTDB_NONE, \
- .details.get_withdraw.label_source = _label_source, \
+ .details.get_withdraw.label_coin = _label_coin, \
}
/**
+ * Composit command representing a coin withdrawal
+ * It first access the reserve history to check the ballance
+ * and hen emits a coin.
+ *
+ * @exposes #PERF_TALER_MINTDB_BLINDCOIN
+ *
+ * @param _label the label of this command
+ * @param _label_reserve the reserve used to provide currency
+ * @param _label_dki the denomination of the created coin
+ */
+#define PERF_TALER_MINTDB_INIT_CMD_WITHDRAWAL(_label, _label_dki, _label_reserve) \
+ PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY("", _label_reserve), \
+ PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve),
+
+
+/**
* The type of data stored in #PERF_TALER_MINTDB_Memory
*/
enum PERF_TALER_MINTDB_Type
@@ -458,6 +505,11 @@ enum PERF_TALER_MINTDB_CMD_Name
PERF_TALER_MINTDB_CMD_GET_RESERVE,
/**
+ * Get the history of a reserve
+ */
+ PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY,
+
+ /**
* Insert informations about a withdrawal in the database
*/
PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW,
@@ -632,7 +684,7 @@ union PERF_TALER_MINTDB_CMD_Details
/**
* The label of the source of the deposit to check
*/
- const char *label_source;
+ const char *label_deposit;
} get_deposit;
@@ -644,11 +696,23 @@ union PERF_TALER_MINTDB_CMD_Details
/**
* The label of the source of the reserve to check
*/
- const char *label_source;
+ const char *label_reserve;
} get_reserve;
/**
+ * Extra data requiered for the #PERF_TALER_MINTDB_CMD_GET_RESERVE command
+ */
+ struct PERF_TALER_MINTDB_CMD_getReserveHistoryDetails
+ {
+ /**
+ * The label of the source of the reserve to check
+ */
+ const char *label_reserve;
+ } get_reserve_history;
+
+
+ /**
* Extra data requiered by the #PERF_TALER_MINTDB_CMD_GET_DENOMINATION command
*/
struct PERF_TALER_MINTDB_CMD_getDenominationDetails
@@ -656,7 +720,7 @@ union PERF_TALER_MINTDB_CMD_Details
/**
* The label of the source of the denomination to check
*/
- const char *label_source;
+ const char *label_denom;
} get_denomination;
@@ -682,9 +746,9 @@ union PERF_TALER_MINTDB_CMD_Details
struct PERF_TALER_MINTDB_CMD_getWithdraw
{
/**
- * label of the source for the withdra information
+ * label of the source for the coin information
*/
- const char *label_source;
+ const char *label_coin;
} get_withdraw;
};