diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-15 11:20:27 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-15 11:20:27 +0200 |
commit | 5503c78160d701b85cecfe20af670808becacd39 (patch) | |
tree | 254f9aea8c4cf7b9dbe9adb69760d6cecd8dbf27 | |
parent | 7dca6dacb90390e08df104ad983f8477f0af4a5b (diff) | |
download | exchange-5503c78160d701b85cecfe20af670808becacd39.tar.gz exchange-5503c78160d701b85cecfe20af670808becacd39.zip |
remove unused, unclean perf logic (we should measure using the logic in the src/benchmark/ directory anyway)
-rw-r--r-- | src/exchangedb/Makefile.am | 30 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb.c | 382 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_init.c | 527 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_init.h | 215 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_interpreter.c | 1754 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_interpreter.h | 1145 | ||||
-rw-r--r-- | src/exchangedb/perf_taler_exchangedb_values.h | 25 | ||||
-rw-r--r-- | src/exchangedb/test_perf_taler_exchangedb.c | 188 |
8 files changed, 2 insertions, 4264 deletions
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 03322f8c5..1a8665849 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am | |||
@@ -64,9 +64,7 @@ check_PROGRAMS = \ | |||
64 | test-exchangedb-denomkeys \ | 64 | test-exchangedb-denomkeys \ |
65 | test-exchangedb-fees \ | 65 | test-exchangedb-fees \ |
66 | test-exchangedb-signkeys \ | 66 | test-exchangedb-signkeys \ |
67 | test-exchangedb-postgres \ | 67 | test-exchangedb-postgres |
68 | test-perf-taler-exchangedb \ | ||
69 | perf-exchangedb | ||
70 | 68 | ||
71 | AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; | 69 | AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; |
72 | TESTS = \ | 70 | TESTS = \ |
@@ -74,8 +72,7 @@ TESTS = \ | |||
74 | test-exchangedb-denomkeys \ | 72 | test-exchangedb-denomkeys \ |
75 | test-exchangedb-fees \ | 73 | test-exchangedb-fees \ |
76 | test-exchangedb-postgres \ | 74 | test-exchangedb-postgres \ |
77 | test-exchangedb-signkeys \ | 75 | test-exchangedb-signkeys |
78 | test-perf-taler-exchangedb | ||
79 | 76 | ||
80 | test_exchangedb_auditors_SOURCES = \ | 77 | test_exchangedb_auditors_SOURCES = \ |
81 | test_exchangedb_auditors.c | 78 | test_exchangedb_auditors.c |
@@ -115,28 +112,5 @@ test_exchangedb_postgres_LDADD = \ | |||
115 | -ljansson \ | 112 | -ljansson \ |
116 | -lgnunetutil | 113 | -lgnunetutil |
117 | 114 | ||
118 | test_perf_taler_exchangedb_SOURCES = \ | ||
119 | test_perf_taler_exchangedb.c \ | ||
120 | perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \ | ||
121 | perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h | ||
122 | test_perf_taler_exchangedb_LDADD = \ | ||
123 | libtalerexchangedb.la \ | ||
124 | $(top_srcdir)/src/util/libtalerutil.la \ | ||
125 | $(top_srcdir)/src/pq/libtalerpq.la \ | ||
126 | -lgnunetutil \ | ||
127 | -ljansson | ||
128 | |||
129 | perf_exchangedb_SOURCES = \ | ||
130 | perf_taler_exchangedb.c \ | ||
131 | perf_taler_exchangedb_init.c perf_taler_exchangedb_init.h \ | ||
132 | perf_taler_exchangedb_interpreter.c perf_taler_exchangedb_interpreter.h | ||
133 | perf_exchangedb_LDADD = \ | ||
134 | libtalerexchangedb.la \ | ||
135 | $(top_srcdir)/src/util/libtalerutil.la \ | ||
136 | $(top_srcdir)/src/pq/libtalerpq.la \ | ||
137 | -lgnunetutil \ | ||
138 | -ljansson | ||
139 | |||
140 | |||
141 | EXTRA_test_exchangedb_postgres_DEPENDENCIES = \ | 115 | EXTRA_test_exchangedb_postgres_DEPENDENCIES = \ |
142 | libtaler_plugin_exchangedb_postgres.la | 116 | 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 64fde0c1d..000000000 --- a/src/exchangedb/perf_taler_exchangedb.c +++ /dev/null | |||
@@ -1,382 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014-2018 Taler Systems SA | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchangedb/perf_taler_exchangedb.c | ||
18 | * @brief Exchange database performance analysis | ||
19 | * @author Nicolas Fournier | ||
20 | * @author Christian Grothoff | ||
21 | */ | ||
22 | #include "platform.h" | ||
23 | #include "perf_taler_exchangedb_interpreter.h" | ||
24 | |||
25 | |||
26 | #define NB_DENOMINATION_INIT 15 | ||
27 | #define NB_DENOMINATION_SAVE 15 | ||
28 | |||
29 | #define SMALL 1000 | ||
30 | #define BIG 10000 | ||
31 | #define BIGGER 100000 | ||
32 | |||
33 | #define NB_RESERVE_INIT BIGGER | ||
34 | #define NB_RESERVE_SAVE BIG | ||
35 | |||
36 | #define NB_DEPOSIT_INIT BIGGER | ||
37 | #define NB_DEPOSIT_SAVE BIG | ||
38 | |||
39 | #define NB_WITHDRAW_INIT BIGGER | ||
40 | #define NB_WITHDRAW_SAVE BIG | ||
41 | |||
42 | #define NB_REFRESH_INIT BIGGER | ||
43 | #define NB_REFRESH_SAVE BIG | ||
44 | |||
45 | #define NB_MELT_INIT BIG | ||
46 | #define NB_MELT_SAVE SMALL | ||
47 | |||
48 | /** | ||
49 | * Runs the performances tests for the exchange database | ||
50 | * and logs the results using Gauger | ||
51 | */ | ||
52 | int | ||
53 | main (int argc, char **argv) | ||
54 | { | ||
55 | int ret; | ||
56 | struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = { | ||
57 | /* Denomination used to create coins */ | ||
58 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Initializing database"), | ||
59 | |||
60 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", | ||
61 | NB_DENOMINATION_INIT), | ||
62 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
63 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), | ||
64 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", | ||
65 | "01 - denomination"), | ||
66 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
67 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", | ||
68 | "01 - denomination loop", | ||
69 | "01 - denomination", | ||
70 | NB_DENOMINATION_SAVE), | ||
71 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - end", | ||
72 | "01 - denomination loop"), | ||
73 | /* End of initialization */ | ||
74 | /* Reserve initialization */ | ||
75 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", | ||
76 | NB_RESERVE_INIT), | ||
77 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), | ||
78 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", | ||
79 | "02 - reserve"), | ||
80 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", | ||
81 | "02 - init reserve loop", | ||
82 | "02 - reserve", | ||
83 | NB_RESERVE_SAVE), | ||
84 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - end", | ||
85 | "02 - init reserve loop"), | ||
86 | /* End reserve init */ | ||
87 | /* Withdrawal initialization */ | ||
88 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", | ||
89 | NB_WITHDRAW_INIT), | ||
90 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
91 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", | ||
92 | "03 - init withdraw loop", | ||
93 | "01 - save denomination"), | ||
94 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", | ||
95 | "03 - init withdraw loop", | ||
96 | "02 - save reserve"), | ||
97 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", | ||
98 | "03 - denomination load", | ||
99 | "03 - reserve load"), | ||
100 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert", | ||
101 | "03 - withdraw"), | ||
102 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
103 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin", | ||
104 | "03 - init withdraw loop", | ||
105 | "03 - withdraw", | ||
106 | NB_WITHDRAW_SAVE), | ||
107 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - end", | ||
108 | "03 - init withdraw loop"), | ||
109 | /*End of withdrawal initialization */ | ||
110 | /*Deposit initialization */ | ||
111 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", | ||
112 | NB_DEPOSIT_INIT), | ||
113 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
114 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load", | ||
115 | "04 - deposit init loop", | ||
116 | "03 - save coin"), | ||
117 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit", | ||
118 | "04 - coin load"), | ||
119 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert", | ||
120 | "04 - deposit"), | ||
121 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
122 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", | ||
123 | "04 - deposit init loop", | ||
124 | "04 - deposit", | ||
125 | NB_DEPOSIT_SAVE), | ||
126 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
127 | "04 - deposit init loop"), | ||
128 | /* End of deposit initialization */ | ||
129 | /* Session initialization */ | ||
130 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("05 - refresh session init loop", | ||
131 | NB_REFRESH_INIT), | ||
132 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
133 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - denomination load", | ||
134 | "05 - refresh session init loop", | ||
135 | "01 - save denomination"), | ||
136 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - reserve load", | ||
137 | "05 - refresh session init loop", | ||
138 | "02 - save reserve"), | ||
139 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("05 - withdraw", | ||
140 | "05 - denomination load", | ||
141 | "05 - reserve load"), | ||
142 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( | ||
143 | "05 - refresh session", | ||
144 | "05 - withdraw"), | ||
145 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("05 - session array", | ||
146 | "05 - refresh session init loop", | ||
147 | "05 - refresh session", | ||
148 | NB_RESERVE_SAVE), | ||
149 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
150 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("05 - end", | ||
151 | "05 - refresh session init loop"), | ||
152 | /* End of refresh session initialization */ | ||
153 | /* Refresh melt initialization */ | ||
154 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("06 - refresh melt init loop", | ||
155 | NB_MELT_INIT), | ||
156 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
157 | /* TODO: initialize using coins & sessions created localy | ||
158 | * in order to make sure the same coin are not melted twice*/ | ||
159 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - session hash", | ||
160 | "06 - refresh melt init loop", | ||
161 | "05 - session array"), | ||
162 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - coin", | ||
163 | "06 - refresh melt init loop", | ||
164 | "03 - save coin"), | ||
165 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
166 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("06 - end", | ||
167 | "06 - refresh melt init loop"), | ||
168 | /* End of refresh melt initialization */ | ||
169 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of initialization"), | ||
170 | |||
171 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Start of performances measuring"), | ||
172 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - start"), | ||
173 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("21 - reserve insert measure", | ||
174 | NB_RESERVE_SAVE), | ||
175 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("21 - reserve"), | ||
176 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("21 - insert", | ||
177 | "21 - reserve"), | ||
178 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
179 | "21 - reserve insert measure"), | ||
180 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - stop"), | ||
181 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("21 - gauger", | ||
182 | "21 - start", | ||
183 | "21 - stop", | ||
184 | "POSTGRES", | ||
185 | "Number of reserve inserted per second", | ||
186 | "item/sec", | ||
187 | NB_RESERVE_SAVE), | ||
188 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve insertion"), | ||
189 | |||
190 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - start"), | ||
191 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("22 - reserve load measure", | ||
192 | NB_RESERVE_SAVE), | ||
193 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("22 - reserve", | ||
194 | "22 - reserve load measure", | ||
195 | "02 - save reserve"), | ||
196 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE ("22 - get", | ||
197 | "22 - reserve"), | ||
198 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
199 | "22 - reserve load measure"), | ||
200 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - stop"), | ||
201 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
202 | "22 - start", | ||
203 | "22 - stop", | ||
204 | "POSTGRES", | ||
205 | "Number of reserve loaded per second", | ||
206 | "item/sec", | ||
207 | NB_RESERVE_SAVE), | ||
208 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve retreival"), | ||
209 | |||
210 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - start"), | ||
211 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("23 - reserve history measure", | ||
212 | NB_RESERVE_SAVE), | ||
213 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("23 - reserve", | ||
214 | "23 - reserve history measure", | ||
215 | "02 - save reserve"), | ||
216 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY ("", | ||
217 | "23 - reserve"), | ||
218 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
219 | "23 - reserve history measure"), | ||
220 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - stop"), | ||
221 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
222 | "23 - start", | ||
223 | "23 - stop", | ||
224 | "POSTGRES", | ||
225 | "Number of reserve history loaded per second", | ||
226 | "item/sec", | ||
227 | NB_RESERVE_SAVE), | ||
228 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve history access"), | ||
229 | |||
230 | |||
231 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - start"), | ||
232 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("24 - withdraw insert measure", | ||
233 | NB_WITHDRAW_SAVE), | ||
234 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - reserve", | ||
235 | "24 - withdraw insert measure", | ||
236 | "02 - save reserve"), | ||
237 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - denomination", | ||
238 | "24 - withdraw insert measure", | ||
239 | "01 - save denomination"), | ||
240 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("24 - withdraw", | ||
241 | "24 - denomination", | ||
242 | "24 - reserve"), | ||
243 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("24 - insert", | ||
244 | "24 - withdraw"), | ||
245 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
246 | "24 - withdraw insert measure"), | ||
247 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - stop"), | ||
248 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
249 | "24 - start", | ||
250 | "24 - stop", | ||
251 | "POSTGRES", | ||
252 | "Number of withdraw insert per second", | ||
253 | "item/sec", | ||
254 | NB_WITHDRAW_SAVE), | ||
255 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw insertion"), | ||
256 | |||
257 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - start"), | ||
258 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("25 - withdraw insert measure", | ||
259 | NB_RESERVE_SAVE), | ||
260 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("25 - coin", | ||
261 | "25 - withdraw insert measure", | ||
262 | "03 - save coin"), | ||
263 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW ("", | ||
264 | "25 - coin"), | ||
265 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
266 | "25 - withdraw insert measure"), | ||
267 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - stop"), | ||
268 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
269 | "25 - start", | ||
270 | "25 - stop", | ||
271 | "POSTGRES", | ||
272 | "Number of withdraw loaded per second", | ||
273 | "item/sec", | ||
274 | NB_RESERVE_SAVE), | ||
275 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw loading"), | ||
276 | |||
277 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - start"), | ||
278 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("26 - get coin transaction", | ||
279 | NB_WITHDRAW_SAVE), | ||
280 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("26 - coin", | ||
281 | "26 - get coin transaction", | ||
282 | "03 - save coin"), | ||
283 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION ("", | ||
284 | "26 - coin"), | ||
285 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
286 | "26 - get coin transaction"), | ||
287 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - end"), | ||
288 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
289 | "26 - start", | ||
290 | "26 - end", | ||
291 | "POSTGRES", | ||
292 | "Number of coin transaction history loaded per second", | ||
293 | "item/sec", | ||
294 | NB_WITHDRAW_SAVE), | ||
295 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of transaction loading"), | ||
296 | |||
297 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - start"), | ||
298 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("27 - /reserve/withdraw", | ||
299 | NB_WITHDRAW_SAVE), | ||
300 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - reserve", | ||
301 | "27 - /reserve/withdraw", | ||
302 | "02 - save reserve"), | ||
303 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - dki", | ||
304 | "27 - /reserve/withdraw", | ||
305 | "01 - save denomination"), | ||
306 | PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN ("", | ||
307 | "27 - dki", | ||
308 | "27 - reserve"), | ||
309 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
310 | "27 - /reserve/withdraw"), | ||
311 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - end"), | ||
312 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
313 | "27 - start", | ||
314 | "27 - end", | ||
315 | "POSTGRES", | ||
316 | "Number of /reserve/withdraw per second", | ||
317 | "item/sec", | ||
318 | NB_WITHDRAW_SAVE), | ||
319 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"), | ||
320 | |||
321 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - start"), | ||
322 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("28 - /deposit", | ||
323 | NB_DEPOSIT_SAVE), | ||
324 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("28 - coin", | ||
325 | "28 - /deposit", | ||
326 | "03 - save coin"), | ||
327 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT ("28 - deposit", | ||
328 | "28 - coin"), | ||
329 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
330 | "28 - /deposit"), | ||
331 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - stop"), | ||
332 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
333 | "28 - start", | ||
334 | "28 - stop", | ||
335 | "POSTGRES", | ||
336 | "Number of /deposit per second", | ||
337 | "item/sec", | ||
338 | NB_DEPOSIT_SAVE), | ||
339 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - start"), | ||
340 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("29 - insert refresh session", | ||
341 | NB_REFRESH_SAVE), | ||
342 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
343 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - denomination load", | ||
344 | "29 - insert refresh session", | ||
345 | "01 - save denomination"), | ||
346 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("29 - reserve load", | ||
347 | "29 - insert refresh session", | ||
348 | "02 - save reserve"), | ||
349 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("29 - withdraw", | ||
350 | "29 - denomination load", | ||
351 | "29 - reserve load"), | ||
352 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( | ||
353 | "29 - refresh session", | ||
354 | "29 - withdraw"), | ||
355 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("29 - session array", | ||
356 | "29 - insert refresh session", | ||
357 | "29 - refresh session", | ||
358 | NB_RESERVE_SAVE), | ||
359 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
360 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
361 | "29 - insert refresh session"), | ||
362 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - stop"), | ||
363 | PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", | ||
364 | "29 - start", | ||
365 | "29 - stop", | ||
366 | "POSTGRES", | ||
367 | "Number of refresh session inserted per second", | ||
368 | "item/sec", | ||
369 | NB_REFRESH_SAVE), | ||
370 | PERF_TALER_EXCHANGEDB_INIT_CMD_END (""), | ||
371 | }; | ||
372 | |||
373 | ret = PERF_TALER_EXCHANGEDB_run_benchmark ( | ||
374 | "perf-taler-exchangedb", | ||
375 | "./test-exchange-db-postgres.conf", | ||
376 | (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END ( | ||
377 | "")}, | ||
378 | benchmark); | ||
379 | if (GNUNET_SYSERR == ret) | ||
380 | return 1; | ||
381 | return 0; | ||
382 | } | ||
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c deleted file mode 100644 index d27634bd8..000000000 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ /dev/null | |||
@@ -1,527 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V. | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchangedb/perf_taler_exchangedb_init.c | ||
18 | * @brief Interpreter library for exchange database performance analysis | ||
19 | * @author Nicolas Fournier | ||
20 | * @author Christian Grothoff | ||
21 | */ | ||
22 | #include "platform.h" | ||
23 | #include "perf_taler_exchangedb_init.h" | ||
24 | #include <gnunet/gnunet_signatures.h> | ||
25 | #include "taler_signatures.h" | ||
26 | #include "taler_amount_lib.h" | ||
27 | |||
28 | |||
29 | #define CURRENCY "EUR" | ||
30 | #define PERF_TALER_EXCHANGEDB_RSA_SIZE 512 | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Generate a dummy DenominationKeyInformation for testing purposes | ||
35 | * @return a dummy denomination key | ||
36 | */ | ||
37 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * | ||
38 | PERF_TALER_EXCHANGEDB_denomination_init () | ||
39 | { | ||
40 | struct GNUNET_CRYPTO_EddsaPrivateKey *master_prvt; | ||
41 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; | ||
42 | struct TALER_DenominationPrivateKey denom_priv; | ||
43 | struct TALER_DenominationPublicKey denom_pub; | ||
44 | struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; | ||
45 | |||
46 | master_prvt = GNUNET_CRYPTO_eddsa_key_create (); | ||
47 | |||
48 | dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); | ||
49 | GNUNET_assert (NULL != dki); | ||
50 | denom_priv.rsa_private_key | ||
51 | = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_EXCHANGEDB_RSA_SIZE); | ||
52 | GNUNET_assert (NULL != denom_priv.rsa_private_key); | ||
53 | denom_pub.rsa_public_key = | ||
54 | GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key); | ||
55 | GNUNET_assert (NULL != denom_pub.rsa_public_key); | ||
56 | {/* issue */ | ||
57 | struct TALER_MasterSignatureP signature; | ||
58 | struct TALER_DenominationKeyValidityPS properties; | ||
59 | |||
60 | {/* properties */ | ||
61 | struct TALER_Amount amount; | ||
62 | struct GNUNET_TIME_Absolute now; | ||
63 | |||
64 | properties.purpose.purpose = htonl ( | ||
65 | TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); | ||
66 | properties.purpose.size = htonl (sizeof (struct | ||
67 | TALER_DenominationKeyValidityPS)); | ||
68 | GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, | ||
69 | &properties.master.eddsa_pub); | ||
70 | now = GNUNET_TIME_absolute_get (); | ||
71 | (void) GNUNET_TIME_round_abs (&now); | ||
72 | properties.start = GNUNET_TIME_absolute_hton (now); | ||
73 | properties.expire_withdraw = GNUNET_TIME_absolute_hton ( | ||
74 | GNUNET_TIME_UNIT_FOREVER_ABS); | ||
75 | properties.expire_deposit = GNUNET_TIME_absolute_hton ( | ||
76 | GNUNET_TIME_UNIT_FOREVER_ABS); | ||
77 | properties.expire_legal = GNUNET_TIME_absolute_hton ( | ||
78 | GNUNET_TIME_UNIT_FOREVER_ABS); | ||
79 | GNUNET_assert (GNUNET_OK == | ||
80 | TALER_string_to_amount (CURRENCY ":1.1", &amount)); | ||
81 | TALER_amount_hton (&properties.value, &amount); | ||
82 | GNUNET_assert (GNUNET_OK == | ||
83 | TALER_string_to_amount (CURRENCY ":0.1", &amount)); | ||
84 | TALER_amount_hton (&properties.fee_withdraw, &amount); | ||
85 | TALER_amount_hton (&properties.fee_deposit, &amount); | ||
86 | TALER_amount_hton (&properties.fee_refresh, &amount); | ||
87 | TALER_amount_hton (&properties.fee_refund, &amount); | ||
88 | GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, | ||
89 | &properties.denom_hash); | ||
90 | issue.properties = properties; | ||
91 | } | ||
92 | {/* signature */ | ||
93 | GNUNET_CRYPTO_eddsa_sign (master_prvt, | ||
94 | &properties.purpose, | ||
95 | &signature.eddsa_signature); | ||
96 | issue.signature = signature; | ||
97 | } | ||
98 | } | ||
99 | dki->denom_priv = denom_priv; | ||
100 | dki->denom_pub = denom_pub; | ||
101 | dki->issue = issue; | ||
102 | GNUNET_free (master_prvt); | ||
103 | return dki; | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Copies the given denomination | ||
109 | * @param reserve the deposit copy | ||
110 | * @return a copy of @a deposit; NULL if error | ||
111 | */ | ||
112 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * | ||
113 | PERF_TALER_EXCHANGEDB_denomination_copy (const struct | ||
114 | TALER_EXCHANGEDB_DenominationKeyIssueInformation | ||
115 | *dki) | ||
116 | { | ||
117 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy; | ||
118 | |||
119 | GNUNET_assert (NULL != | ||
120 | (copy = GNUNET_new (struct | ||
121 | TALER_EXCHANGEDB_DenominationKeyIssueInformation))); | ||
122 | {/* denom_priv */ | ||
123 | copy->denom_priv.rsa_private_key = | ||
124 | GNUNET_CRYPTO_rsa_private_key_dup (dki->denom_priv.rsa_private_key); | ||
125 | } | ||
126 | {/* denom_pub */ | ||
127 | copy->denom_pub.rsa_public_key = | ||
128 | GNUNET_CRYPTO_rsa_public_key_dup (dki->denom_pub.rsa_public_key); | ||
129 | } | ||
130 | {/* issue */ | ||
131 | copy->issue.properties = dki->issue.properties; | ||
132 | copy->issue.signature = dki->issue.signature; | ||
133 | } | ||
134 | return copy; | ||
135 | } | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Free memory of a DenominationKeyIssueInformation | ||
140 | * @param dki pointer to the struct to free | ||
141 | */ | ||
142 | int | ||
143 | PERF_TALER_EXCHANGEDB_denomination_free (struct | ||
144 | TALER_EXCHANGEDB_DenominationKeyIssueInformation | ||
145 | *dki) | ||
146 | { | ||
147 | if (NULL == dki) | ||
148 | return GNUNET_OK; | ||
149 | GNUNET_CRYPTO_rsa_private_key_free (dki->denom_priv.rsa_private_key); | ||
150 | GNUNET_CRYPTO_rsa_public_key_free (dki->denom_pub.rsa_public_key); | ||
151 | |||
152 | GNUNET_free (dki); | ||
153 | return GNUNET_OK; | ||
154 | } | ||
155 | |||
156 | |||
157 | /** | ||
158 | * Generate a dummy reserve for testing | ||
159 | * @return a reserve with 1000 EUR in it | ||
160 | */ | ||
161 | struct PERF_TALER_EXCHANGEDB_Reserve * | ||
162 | PERF_TALER_EXCHANGEDB_reserve_init () | ||
163 | { | ||
164 | struct PERF_TALER_EXCHANGEDB_Reserve *reserve; | ||
165 | |||
166 | GNUNET_assert (NULL != | ||
167 | (reserve = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve))); | ||
168 | {/* private */ | ||
169 | struct GNUNET_CRYPTO_EddsaPrivateKey *private; | ||
170 | private = GNUNET_CRYPTO_eddsa_key_create (); | ||
171 | GNUNET_assert (NULL != private); | ||
172 | reserve->private = *private; | ||
173 | GNUNET_free (private); | ||
174 | } | ||
175 | |||
176 | GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private, | ||
177 | &reserve->reserve.pub.eddsa_pub); | ||
178 | GNUNET_assert (GNUNET_OK == | ||
179 | TALER_string_to_amount (CURRENCY ":1000", | ||
180 | &reserve->reserve.balance)); | ||
181 | reserve->reserve.expiry = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
182 | return reserve; | ||
183 | } | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Copies the given reserve | ||
188 | * @param reserve the reserve to copy | ||
189 | * @return a copy of @a reserve; NULL if error | ||
190 | */ | ||
191 | struct PERF_TALER_EXCHANGEDB_Reserve * | ||
192 | PERF_TALER_EXCHANGEDB_reserve_copy (const struct | ||
193 | PERF_TALER_EXCHANGEDB_Reserve *reserve) | ||
194 | { | ||
195 | struct PERF_TALER_EXCHANGEDB_Reserve *copy; | ||
196 | GNUNET_assert (NULL != | ||
197 | (copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Reserve))); | ||
198 | *copy = *reserve; | ||
199 | return copy; | ||
200 | } | ||
201 | |||
202 | |||
203 | /** | ||
204 | * Free memory of a reserve | ||
205 | * @param reserve pointer to the structure to be freed | ||
206 | */ | ||
207 | int | ||
208 | PERF_TALER_EXCHANGEDB_reserve_free (struct | ||
209 | PERF_TALER_EXCHANGEDB_Reserve *reserve) | ||
210 | { | ||
211 | if (NULL == reserve) | ||
212 | return GNUNET_OK; | ||
213 | GNUNET_free (reserve); | ||
214 | return GNUNET_OK; | ||
215 | } | ||
216 | |||
217 | |||
218 | /** | ||
219 | * Generate a dummy deposit for testing purposes | ||
220 | * | ||
221 | * @param dki the denomination key used to sign the key | ||
222 | */ | ||
223 | struct TALER_EXCHANGEDB_Deposit * | ||
224 | PERF_TALER_EXCHANGEDB_deposit_init (const struct | ||
225 | PERF_TALER_EXCHANGEDB_Coin *coin) | ||
226 | { | ||
227 | struct TALER_EXCHANGEDB_Deposit *deposit; | ||
228 | struct TALER_CoinSpendSignatureP csig; | ||
229 | struct TALER_MerchantPublicKeyP merchant_pub; | ||
230 | struct GNUNET_HashCode h_contract_terms; | ||
231 | struct GNUNET_HashCode h_wire; | ||
232 | struct GNUNET_TIME_Absolute timestamp; | ||
233 | struct GNUNET_TIME_Absolute refund_deadline; | ||
234 | struct TALER_Amount amount_with_fee; | ||
235 | struct TALER_Amount deposit_fee; | ||
236 | |||
237 | deposit = GNUNET_new (struct TALER_EXCHANGEDB_Deposit); | ||
238 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | ||
239 | &h_contract_terms); | ||
240 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | ||
241 | &h_wire); | ||
242 | { // csig | ||
243 | struct u32_presign | ||
244 | { | ||
245 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
246 | struct GNUNET_HashCode h_wire; | ||
247 | struct GNUNET_HashCode h_contract_terms; | ||
248 | } unsigned_data; | ||
249 | |||
250 | unsigned_data.h_contract_terms = h_contract_terms; | ||
251 | unsigned_data.h_wire = h_wire; | ||
252 | unsigned_data.purpose.size = htonl (sizeof (struct u32_presign)); | ||
253 | unsigned_data.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TEST); | ||
254 | GNUNET_assert (GNUNET_OK == | ||
255 | GNUNET_CRYPTO_eddsa_sign (&coin->priv, | ||
256 | &unsigned_data.purpose, | ||
257 | &csig.eddsa_signature)); | ||
258 | } | ||
259 | { // merchant_pub | ||
260 | struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv; | ||
261 | |||
262 | eddsa_prv = GNUNET_CRYPTO_eddsa_key_create (); | ||
263 | GNUNET_assert (NULL != eddsa_prv); | ||
264 | GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prv, | ||
265 | &merchant_pub.eddsa_pub); | ||
266 | GNUNET_free (eddsa_prv); | ||
267 | } | ||
268 | timestamp = GNUNET_TIME_absolute_get (); | ||
269 | (void) GNUNET_TIME_round_abs (×tamp); | ||
270 | refund_deadline = GNUNET_TIME_absolute_get (); | ||
271 | (void) GNUNET_TIME_round_abs (&refund_deadline); | ||
272 | GNUNET_assert (GNUNET_OK == | ||
273 | TALER_string_to_amount (CURRENCY ":1.1", | ||
274 | &amount_with_fee)); | ||
275 | GNUNET_assert (GNUNET_OK == | ||
276 | TALER_string_to_amount (CURRENCY ":0.1", | ||
277 | &deposit_fee)); | ||
278 | { | ||
279 | deposit->coin.coin_pub = coin->public_info.coin_pub; | ||
280 | deposit->coin.denom_pub_hash = coin->public_info.denom_pub_hash; | ||
281 | deposit->coin.denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup ( | ||
282 | coin->public_info.denom_sig.rsa_signature); | ||
283 | GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); | ||
284 | } | ||
285 | deposit->csig = csig; | ||
286 | deposit->h_contract_terms = h_contract_terms; | ||
287 | deposit->h_wire = h_wire; | ||
288 | deposit->receiver_wire_account | ||
289 | = json_pack ("{s:s, s:s}", | ||
290 | "url", "payto://iban/DE67830654080004822650", | ||
291 | "salt", "this-is-a-salt-value"); | ||
292 | deposit->timestamp = timestamp; | ||
293 | deposit->refund_deadline = refund_deadline; | ||
294 | deposit->amount_with_fee = amount_with_fee; | ||
295 | deposit->deposit_fee = deposit_fee; | ||
296 | return deposit; | ||
297 | } | ||
298 | |||
299 | |||
300 | /** | ||
301 | * Copies the given deposit | ||
302 | * @param reserve the deposit copy | ||
303 | * @return a copy of @a deposit; NULL if error | ||
304 | */ | ||
305 | struct TALER_EXCHANGEDB_Deposit * | ||
306 | PERF_TALER_EXCHANGEDB_deposit_copy (const struct | ||
307 | TALER_EXCHANGEDB_Deposit *deposit) | ||
308 | { | ||
309 | struct TALER_EXCHANGEDB_Deposit *copy; | ||
310 | |||
311 | copy = GNUNET_new (struct TALER_EXCHANGEDB_Deposit); | ||
312 | *copy = *deposit; | ||
313 | copy->receiver_wire_account = json_incref (deposit->receiver_wire_account); | ||
314 | copy->coin.denom_sig.rsa_signature = | ||
315 | GNUNET_CRYPTO_rsa_signature_dup (deposit->coin.denom_sig.rsa_signature); | ||
316 | return copy; | ||
317 | } | ||
318 | |||
319 | |||
320 | /** | ||
321 | * Free memory of a deposit | ||
322 | * @param deposit pointer to the structure to free | ||
323 | */ | ||
324 | int | ||
325 | PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit) | ||
326 | { | ||
327 | if (NULL == deposit) | ||
328 | return GNUNET_OK; | ||
329 | GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature); | ||
330 | json_decref (deposit->receiver_wire_account); | ||
331 | GNUNET_free (deposit); | ||
332 | return GNUNET_OK; | ||
333 | } | ||
334 | |||
335 | |||
336 | /** | ||
337 | * Generate a CollectableBlindcoin for testing purpuses | ||
338 | * @param dki denomination key used to sign the coin | ||
339 | * @param reserve reserve providing the money for the coin | ||
340 | * @return a randomly generated CollectableBlindcoin | ||
341 | */ | ||
342 | struct PERF_TALER_EXCHANGEDB_Coin * | ||
343 | PERF_TALER_EXCHANGEDB_coin_init ( | ||
344 | const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, | ||
345 | const struct PERF_TALER_EXCHANGEDB_Reserve *reserve) | ||
346 | { | ||
347 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
348 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv; | ||
349 | struct GNUNET_HashCode hc; | ||
350 | |||
351 | coin = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin); | ||
352 | GNUNET_assert (NULL != coin); | ||
353 | /* priv */ | ||
354 | |||
355 | priv = GNUNET_CRYPTO_eddsa_key_create (); | ||
356 | GNUNET_assert (NULL != priv); | ||
357 | coin->priv = *priv; | ||
358 | GNUNET_free (priv); | ||
359 | |||
360 | /* public_info */ | ||
361 | GNUNET_CRYPTO_eddsa_key_get_public (&coin->priv, | ||
362 | &coin->public_info.coin_pub.eddsa_pub); | ||
363 | GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, | ||
364 | &coin->public_info.denom_pub_hash); | ||
365 | GNUNET_CRYPTO_hash (&coin->public_info.coin_pub, | ||
366 | sizeof (struct TALER_CoinSpendPublicKeyP), | ||
367 | &hc); | ||
368 | coin->public_info.denom_sig.rsa_signature = | ||
369 | GNUNET_CRYPTO_rsa_sign_fdh (dki->denom_priv.rsa_private_key, | ||
370 | &hc); | ||
371 | GNUNET_assert (NULL != coin->public_info.denom_sig.rsa_signature); | ||
372 | |||
373 | /* blind */ | ||
374 | coin->blind.sig.rsa_signature = | ||
375 | GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); | ||
376 | coin->blind.denom_pub_hash = coin->public_info.denom_pub_hash; | ||
377 | GNUNET_assert (NULL != coin->blind.sig.rsa_signature); | ||
378 | TALER_amount_ntoh (&coin->blind.amount_with_fee, | ||
379 | &dki->issue.properties.value); | ||
380 | TALER_amount_ntoh (&coin->blind.withdraw_fee, | ||
381 | &dki->issue.properties.fee_withdraw); | ||
382 | coin->blind.reserve_pub = reserve->reserve.pub; | ||
383 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | ||
384 | &coin->blind.h_coin_envelope); | ||
385 | |||
386 | return coin; | ||
387 | } | ||
388 | |||
389 | |||
390 | /** | ||
391 | * Copies the given coin | ||
392 | * | ||
393 | * @param coin the coin to copy | ||
394 | * @return a copy of coin; NULL if error | ||
395 | */ | ||
396 | struct PERF_TALER_EXCHANGEDB_Coin * | ||
397 | PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin) | ||
398 | { | ||
399 | struct PERF_TALER_EXCHANGEDB_Coin *copy; | ||
400 | |||
401 | copy = GNUNET_new (struct PERF_TALER_EXCHANGEDB_Coin); | ||
402 | /* priv */ | ||
403 | copy->priv = coin->priv; | ||
404 | /* public_info */ | ||
405 | copy->public_info.coin_pub = coin->public_info.coin_pub; | ||
406 | copy->public_info.denom_pub_hash = coin->public_info.denom_pub_hash; | ||
407 | copy->public_info.denom_sig.rsa_signature = | ||
408 | GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); | ||
409 | |||
410 | /* blind */ | ||
411 | copy->blind.sig.rsa_signature = | ||
412 | GNUNET_CRYPTO_rsa_signature_dup (coin->blind.sig.rsa_signature); | ||
413 | copy->blind.denom_pub_hash = coin->blind.denom_pub_hash; | ||
414 | copy->blind.amount_with_fee = coin->blind.amount_with_fee; | ||
415 | copy->blind.withdraw_fee = coin->blind.withdraw_fee; | ||
416 | copy->blind.reserve_pub = coin->blind.reserve_pub; | ||
417 | copy->blind.h_coin_envelope = coin->blind.h_coin_envelope; | ||
418 | copy->blind.reserve_sig = coin->blind.reserve_sig; | ||
419 | |||
420 | return copy; | ||
421 | } | ||
422 | |||
423 | |||
424 | /** | ||
425 | * Free memory of @a coin | ||
426 | * | ||
427 | * @param coin pointer to the structure to free | ||
428 | */ | ||
429 | int | ||
430 | PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin) | ||
431 | { | ||
432 | if (NULL == coin) | ||
433 | return GNUNET_OK; | ||
434 | GNUNET_CRYPTO_rsa_signature_free (coin->public_info.denom_sig.rsa_signature); | ||
435 | GNUNET_CRYPTO_rsa_signature_free (coin->blind.sig.rsa_signature); | ||
436 | GNUNET_free (coin); | ||
437 | return GNUNET_OK; | ||
438 | } | ||
439 | |||
440 | |||
441 | /** | ||
442 | * Create a melt operation | ||
443 | * | ||
444 | * @param rc the commitment of the refresh session | ||
445 | * @param dki the denomination the melted coin uses | ||
446 | * @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt | ||
447 | */ | ||
448 | struct TALER_EXCHANGEDB_RefreshMelt * | ||
449 | PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, | ||
450 | struct PERF_TALER_EXCHANGEDB_Coin *coin) | ||
451 | { | ||
452 | struct TALER_EXCHANGEDB_RefreshMelt *melt; | ||
453 | struct TALER_CoinSpendSignatureP coin_sig; | ||
454 | struct TALER_Amount amount; | ||
455 | struct TALER_Amount amount_with_fee; | ||
456 | |||
457 | { | ||
458 | struct | ||
459 | { | ||
460 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
461 | struct TALER_RefreshCommitmentP rc; | ||
462 | } to_sign; | ||
463 | |||
464 | to_sign.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST; | ||
465 | to_sign.purpose.size = htonl (sizeof (to_sign)); | ||
466 | to_sign.rc = *rc; | ||
467 | GNUNET_CRYPTO_eddsa_sign (&coin->priv, | ||
468 | &to_sign.purpose, | ||
469 | &coin_sig.eddsa_signature); | ||
470 | } | ||
471 | GNUNET_assert (GNUNET_OK == | ||
472 | TALER_string_to_amount (CURRENCY ":1.1", | ||
473 | &amount)); | ||
474 | GNUNET_assert (GNUNET_OK == | ||
475 | TALER_string_to_amount (CURRENCY ":0.1", | ||
476 | &amount_with_fee)); | ||
477 | melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); | ||
478 | melt->session.coin.coin_pub = coin->public_info.coin_pub; | ||
479 | melt->session.coin.denom_sig.rsa_signature = | ||
480 | GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature); | ||
481 | melt->session.coin.denom_pub_hash = coin->public_info.denom_pub_hash; | ||
482 | GNUNET_assert (NULL != melt->session.coin.denom_sig.rsa_signature); | ||
483 | melt->session.coin_sig = coin_sig; | ||
484 | melt->session.rc = *rc; | ||
485 | melt->session.amount_with_fee = amount; | ||
486 | melt->melt_fee = amount_with_fee; | ||
487 | return melt; | ||
488 | } | ||
489 | |||
490 | |||
491 | /** | ||
492 | * Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt | ||
493 | * | ||
494 | * @param melt the refresh melt to copy | ||
495 | * @return an copy of @ melt | ||
496 | */ | ||
497 | struct TALER_EXCHANGEDB_RefreshMelt * | ||
498 | PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct | ||
499 | TALER_EXCHANGEDB_RefreshMelt *melt) | ||
500 | { | ||
501 | struct TALER_EXCHANGEDB_RefreshMelt *copy; | ||
502 | |||
503 | copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); | ||
504 | *copy = *melt; | ||
505 | copy->session.coin.denom_sig.rsa_signature = | ||
506 | GNUNET_CRYPTO_rsa_signature_dup ( | ||
507 | melt->session.coin.denom_sig.rsa_signature); | ||
508 | GNUNET_assert (NULL != copy->session.coin.denom_sig.rsa_signature); | ||
509 | |||
510 | return copy; | ||
511 | } | ||
512 | |||
513 | |||
514 | /** | ||
515 | * Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt | ||
516 | * | ||
517 | * @param melt the #TALER_EXCHANGEDB_RefreshMelt to free | ||
518 | * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR | ||
519 | */ | ||
520 | int | ||
521 | PERF_TALER_EXCHANGEDB_refresh_melt_free (struct | ||
522 | TALER_EXCHANGEDB_RefreshMelt *melt) | ||
523 | { | ||
524 | GNUNET_CRYPTO_rsa_signature_free (melt->session.coin.denom_sig.rsa_signature); | ||
525 | GNUNET_free (melt); | ||
526 | return GNUNET_OK; | ||
527 | } | ||
diff --git a/src/exchangedb/perf_taler_exchangedb_init.h b/src/exchangedb/perf_taler_exchangedb_init.h deleted file mode 100644 index f20b35c5b..000000000 --- a/src/exchangedb/perf_taler_exchangedb_init.h +++ /dev/null | |||
@@ -1,215 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014, 2015 GNUnet e.V. | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchangedb/perf_taler_exchangedb_init.h | ||
18 | * @brief Heler function for creating dummy inputs for the exchange database | ||
19 | * @author Nicolas Fournier | ||
20 | */ | ||
21 | #ifndef __PERF_TALER_EXCHANGEDB_INIT_H___ | ||
22 | #define __PERF_TALER_EXCHANGEDB_INIT_H___ | ||
23 | |||
24 | #include "taler_exchangedb_plugin.h" | ||
25 | |||
26 | |||
27 | #define CURRENCY "EUR" | ||
28 | |||
29 | /** | ||
30 | * All information about a reserve | ||
31 | */ | ||
32 | struct PERF_TALER_EXCHANGEDB_Reserve | ||
33 | { | ||
34 | /** | ||
35 | * Information about a rserve available to the Exchange | ||
36 | */ | ||
37 | struct TALER_EXCHANGEDB_Reserve reserve; | ||
38 | |||
39 | /** | ||
40 | * Private key of a reserve | ||
41 | */ | ||
42 | struct GNUNET_CRYPTO_EddsaPrivateKey private; | ||
43 | }; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * All informations about a coin | ||
48 | */ | ||
49 | struct PERF_TALER_EXCHANGEDB_Coin | ||
50 | { | ||
51 | /** | ||
52 | * Blinded coin, known by the exchange | ||
53 | */ | ||
54 | struct TALER_EXCHANGEDB_CollectableBlindcoin blind; | ||
55 | |||
56 | /** | ||
57 | * Public key of the coin and othes informations | ||
58 | */ | ||
59 | struct TALER_CoinPublicInfo public_info; | ||
60 | |||
61 | /** | ||
62 | * Private key of the coin | ||
63 | */ | ||
64 | struct GNUNET_CRYPTO_EddsaPrivateKey priv; | ||
65 | }; | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Generate a dummy DenominationKeyInformation for testing purposes | ||
70 | * @return a dummy denomination key | ||
71 | */ | ||
72 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * | ||
73 | PERF_TALER_EXCHANGEDB_denomination_init (void); | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Copies the given denomination | ||
78 | * @param reserve the deposit copy | ||
79 | * @return a copy of @a deposit; NULL if error | ||
80 | */ | ||
81 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * | ||
82 | PERF_TALER_EXCHANGEDB_denomination_copy (const struct | ||
83 | TALER_EXCHANGEDB_DenominationKeyIssueInformation | ||
84 | *dki); | ||
85 | |||
86 | |||
87 | /** | ||
88 | * Free memory of a DenominationKeyIssueInformation | ||
89 | * @param dki pointer to the struct to free | ||
90 | */ | ||
91 | int | ||
92 | PERF_TALER_EXCHANGEDB_denomination_free (struct | ||
93 | TALER_EXCHANGEDB_DenominationKeyIssueInformation | ||
94 | *dki); | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Generate a dummy reserve for testing | ||
99 | * @return a reserve with 1000 EUR in it | ||
100 | */ | ||
101 | struct PERF_TALER_EXCHANGEDB_Reserve * | ||
102 | PERF_TALER_EXCHANGEDB_reserve_init (void); | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Copies the given reserve | ||
107 | * @param reserve the reserve to copy | ||
108 | * @return a copy of @a reserve; NULL if error | ||
109 | */ | ||
110 | struct PERF_TALER_EXCHANGEDB_Reserve * | ||
111 | PERF_TALER_EXCHANGEDB_reserve_copy (const struct | ||
112 | PERF_TALER_EXCHANGEDB_Reserve *reserve); | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Free memory of a reserve | ||
117 | * @param reserve pointer to the structure to be freed | ||
118 | */ | ||
119 | int | ||
120 | PERF_TALER_EXCHANGEDB_reserve_free (struct | ||
121 | PERF_TALER_EXCHANGEDB_Reserve *reserve); | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Generate a dummy deposit for testing purposes | ||
126 | * @param dki the denomination key used to sign the key | ||
127 | */ | ||
128 | struct TALER_EXCHANGEDB_Deposit * | ||
129 | PERF_TALER_EXCHANGEDB_deposit_init (const struct | ||
130 | PERF_TALER_EXCHANGEDB_Coin *coin); | ||
131 | |||
132 | |||
133 | /** | ||
134 | * Copies the given deposit | ||
135 | * @param reserve the deposit copy | ||
136 | * @return a copy of @a deposit; NULL if error | ||
137 | */ | ||
138 | struct TALER_EXCHANGEDB_Deposit * | ||
139 | PERF_TALER_EXCHANGEDB_deposit_copy (const struct | ||
140 | TALER_EXCHANGEDB_Deposit *deposit); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Free memory of a deposit | ||
145 | * @param deposit pointer to the structure to free | ||
146 | */ | ||
147 | int | ||
148 | PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit); | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Generate a coin for testing purpuses | ||
153 | * @param dki denomination key used to sign the coin | ||
154 | * @param reserve reserve providing the money for the coin | ||
155 | * @return a randomly generated CollectableBlindcoin | ||
156 | */ | ||
157 | struct PERF_TALER_EXCHANGEDB_Coin * | ||
158 | PERF_TALER_EXCHANGEDB_coin_init (const struct | ||
159 | TALER_EXCHANGEDB_DenominationKeyIssueInformation | ||
160 | *dki, | ||
161 | const struct | ||
162 | PERF_TALER_EXCHANGEDB_Reserve *reserve); | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Copies the given coin | ||
167 | * @param coin the coin to copy | ||
168 | * @return a copy of coin; NULL if error | ||
169 | */ | ||
170 | struct PERF_TALER_EXCHANGEDB_Coin * | ||
171 | PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Liberate memory of @a coin | ||
176 | * @param coin pointer to the structure to free | ||
177 | */ | ||
178 | int | ||
179 | PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin); | ||
180 | |||
181 | |||
182 | /** | ||
183 | * Create a melt operation | ||
184 | * | ||
185 | * @param rc the commitment of the refresh session | ||
186 | * @param dki the denomination the melted coin uses | ||
187 | * @return a pointer to a #TALER_EXCHANGEDB_RefreshMelt | ||
188 | */ | ||
189 | struct TALER_EXCHANGEDB_RefreshMelt * | ||
190 | PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, | ||
191 | struct PERF_TALER_EXCHANGEDB_Coin *coin); | ||
192 | |||
193 | |||
194 | /** | ||
195 | * Copies the internals of a #TALER_EXCHANGEDB_RefreshMelt | ||
196 | * | ||
197 | * @param melt the refresh melt to copy | ||
198 | * @return an copy of @ melt | ||
199 | */ | ||
200 | struct TALER_EXCHANGEDB_RefreshMelt * | ||
201 | PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct | ||
202 | TALER_EXCHANGEDB_RefreshMelt *melt); | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Free the internal memory of a #TALER_EXCHANGEDB_RefreshMelt | ||
207 | * | ||
208 | * @param melt the #TALER_EXCHANGEDB_RefreshMelt to free | ||
209 | * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR | ||
210 | */ | ||
211 | int | ||
212 | PERF_TALER_EXCHANGEDB_refresh_melt_free (struct | ||
213 | TALER_EXCHANGEDB_RefreshMelt *melt); | ||
214 | |||
215 | #endif | ||
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c deleted file mode 100644 index b96db493d..000000000 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ /dev/null | |||
@@ -1,1754 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014-2017 GNUnet e.V. | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchangedb/perf_taler_exchangedb_interpreter.c | ||
18 | * @brief Interpreter library for exchange database performance analysis | ||
19 | * @author Nicolas Fournier | ||
20 | */ | ||
21 | #include "platform.h" | ||
22 | #include "perf_taler_exchangedb_interpreter.h" | ||
23 | #include "perf_taler_exchangedb_init.h" | ||
24 | #include "gauger.h" | ||
25 | |||
26 | |||
27 | /** | ||
28 | * Represents the state of the interpreter | ||
29 | */ | ||
30 | struct PERF_TALER_EXCHANGEDB_interpreter_state | ||
31 | { | ||
32 | /** | ||
33 | * State of the commands | ||
34 | */ | ||
35 | struct PERF_TALER_EXCHANGEDB_Cmd *cmd; | ||
36 | |||
37 | /** | ||
38 | * Database plugin | ||
39 | */ | ||
40 | struct TALER_EXCHANGEDB_Plugin *plugin; | ||
41 | |||
42 | /** | ||
43 | * Current database session | ||
44 | */ | ||
45 | struct TALER_EXCHANGEDB_Session *session; | ||
46 | |||
47 | /** | ||
48 | * The current index of the interpreter | ||
49 | */ | ||
50 | unsigned int i; | ||
51 | }; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Free the memory of @a data | ||
56 | */ | ||
57 | static void | ||
58 | data_free (struct PERF_TALER_EXCHANGEDB_Data *data) | ||
59 | { | ||
60 | switch (data->type) | ||
61 | { | ||
62 | case PERF_TALER_EXCHANGEDB_TIME: | ||
63 | if (NULL == data->data.time) | ||
64 | break; | ||
65 | GNUNET_free (data->data.time); | ||
66 | data->data.time = NULL; | ||
67 | break; | ||
68 | case PERF_TALER_EXCHANGEDB_DEPOSIT: | ||
69 | if (NULL == data->data.deposit) | ||
70 | break; | ||
71 | PERF_TALER_EXCHANGEDB_deposit_free (data->data.deposit); | ||
72 | data->data.deposit = NULL; | ||
73 | break; | ||
74 | case PERF_TALER_EXCHANGEDB_COIN: | ||
75 | if (NULL == data->data.coin) | ||
76 | break; | ||
77 | GNUNET_free (data->data.coin); | ||
78 | data->data.coin = NULL; | ||
79 | break; | ||
80 | case PERF_TALER_EXCHANGEDB_RESERVE: | ||
81 | if (NULL == data->data.reserve) | ||
82 | break; | ||
83 | PERF_TALER_EXCHANGEDB_reserve_free (data->data.reserve); | ||
84 | data->data.reserve = NULL; | ||
85 | break; | ||
86 | case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: | ||
87 | if (NULL == data->data.dki) | ||
88 | break; | ||
89 | PERF_TALER_EXCHANGEDB_denomination_free (data->data.dki); | ||
90 | data->data.dki = NULL; | ||
91 | break; | ||
92 | case PERF_TALER_EXCHANGEDB_REFRESH_HASH: | ||
93 | break; | ||
94 | case PERF_TALER_EXCHANGEDB_NONE: | ||
95 | break; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Copies @a data into @a copy | ||
102 | * | ||
103 | * @param data the data to be copied | ||
104 | * @param[out] copy the copy made | ||
105 | */ | ||
106 | static void | ||
107 | data_copy (const struct PERF_TALER_EXCHANGEDB_Data *data, | ||
108 | struct PERF_TALER_EXCHANGEDB_Data *copy) | ||
109 | { | ||
110 | copy->type = data->type; | ||
111 | switch (data->type) | ||
112 | { | ||
113 | case PERF_TALER_EXCHANGEDB_TIME: | ||
114 | copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute); | ||
115 | *copy->data.time = *data->data.time; | ||
116 | return; | ||
117 | case PERF_TALER_EXCHANGEDB_DEPOSIT: | ||
118 | copy->data.deposit | ||
119 | = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit); | ||
120 | return; | ||
121 | case PERF_TALER_EXCHANGEDB_COIN: | ||
122 | copy->data.coin | ||
123 | = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin); | ||
124 | return; | ||
125 | case PERF_TALER_EXCHANGEDB_RESERVE: | ||
126 | copy->data.reserve | ||
127 | = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve); | ||
128 | return; | ||
129 | case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: | ||
130 | copy->data.dki | ||
131 | = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki); | ||
132 | return; | ||
133 | case PERF_TALER_EXCHANGEDB_REFRESH_HASH: | ||
134 | copy->data.rc = data->data.rc; | ||
135 | break; | ||
136 | case PERF_TALER_EXCHANGEDB_NONE: | ||
137 | break; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Finds the first command in cmd with the name search | ||
144 | * | ||
145 | * @return the index of the first command with name search | ||
146 | * #GNUNET_SYSERR if none found | ||
147 | */ | ||
148 | static int | ||
149 | cmd_find (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd, | ||
150 | const char *search) | ||
151 | { | ||
152 | unsigned int i; | ||
153 | |||
154 | for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) | ||
155 | if (0 == strcmp (cmd[i].label, search)) | ||
156 | return i; | ||
157 | return GNUNET_SYSERR; | ||
158 | } | ||
159 | |||
160 | |||
161 | /** | ||
162 | * Initialization of a command array | ||
163 | * and check for the type of the label | ||
164 | * | ||
165 | * @param cmd the comand array initialized | ||
166 | * @return #GNUNET_OK if the initialization was sucessful | ||
167 | * #GNUNET_SYSERR if there was a probleb. See the log for details | ||
168 | */ | ||
169 | static int | ||
170 | cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) | ||
171 | { | ||
172 | unsigned int i; | ||
173 | |||
174 | for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) | ||
175 | { | ||
176 | switch (cmd[i].command) | ||
177 | { | ||
178 | case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: | ||
179 | { | ||
180 | int ret; | ||
181 | |||
182 | ret = cmd_find (cmd, | ||
183 | cmd[i].details.end_loop.label_loop); | ||
184 | if (GNUNET_SYSERR == ret) | ||
185 | { | ||
186 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
187 | "%d:Undefined reference to %s\n", | ||
188 | i, | ||
189 | cmd[i].details.end_loop.label_loop); | ||
190 | return GNUNET_SYSERR; | ||
191 | } | ||
192 | if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) | ||
193 | { | ||
194 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
195 | "%d:Wrong type reference to %s at %s\n", | ||
196 | i, | ||
197 | cmd[i].details.end_loop.label_loop, | ||
198 | cmd[i].label); | ||
199 | return GNUNET_SYSERR; | ||
200 | } | ||
201 | cmd[i].details.end_loop.index_loop = ret; | ||
202 | } | ||
203 | break; | ||
204 | |||
205 | case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: | ||
206 | { | ||
207 | int ret; | ||
208 | |||
209 | ret = cmd_find (cmd, | ||
210 | cmd[i].details.save_array.label_save); | ||
211 | if (GNUNET_SYSERR == ret) | ||
212 | { | ||
213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
214 | "%d:Undefined reference to %s at %s\n", | ||
215 | i, | ||
216 | cmd[i].details.save_array.label_save, | ||
217 | cmd[i].label); | ||
218 | return GNUNET_SYSERR; | ||
219 | } | ||
220 | if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type) | ||
221 | { | ||
222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
223 | "%d:Wrong type reference to %s at %s\n", | ||
224 | i, | ||
225 | cmd[i].details.save_array.label_save, | ||
226 | cmd[i].label); | ||
227 | return GNUNET_SYSERR; | ||
228 | } | ||
229 | cmd[i].details.save_array.index_save = ret; | ||
230 | |||
231 | ret = cmd_find (cmd, | ||
232 | cmd[i].details.save_array.label_loop); | ||
233 | if (GNUNET_SYSERR == ret) | ||
234 | { | ||
235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
236 | "%d:Undefined reference to %s at %s\n", | ||
237 | i, | ||
238 | cmd[i].details.save_array.label_loop, | ||
239 | cmd[i].label); | ||
240 | return GNUNET_SYSERR; | ||
241 | } | ||
242 | if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) | ||
243 | { | ||
244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
245 | "%d:Wrong type reference to %s at %s\n", | ||
246 | i, | ||
247 | cmd[i].details.save_array.label_loop, | ||
248 | cmd[i].label); | ||
249 | return GNUNET_SYSERR; | ||
250 | } | ||
251 | cmd[i].details.save_array.index_loop = ret; | ||
252 | |||
253 | GNUNET_assert (NULL == cmd[i].details.save_array.data_saved); | ||
254 | cmd[i].details.save_array.data_saved = | ||
255 | GNUNET_new_array (cmd[i].details.save_array.nb_saved, | ||
256 | struct PERF_TALER_EXCHANGEDB_Data); | ||
257 | cmd[i].details.save_array.type_saved = | ||
258 | cmd[cmd[i].details.save_array.index_save].exposed.type; | ||
259 | } | ||
260 | break; | ||
261 | |||
262 | case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: | ||
263 | { | ||
264 | int ret; | ||
265 | |||
266 | ret = cmd_find (cmd, | ||
267 | cmd[i].details.load_array.label_save); | ||
268 | if (GNUNET_SYSERR == ret) | ||
269 | { | ||
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
271 | "%d:Undefined reference to %s at %s\n", | ||
272 | i, | ||
273 | cmd[i].details.load_array.label_save, | ||
274 | cmd[i].label); | ||
275 | return GNUNET_SYSERR; | ||
276 | } | ||
277 | if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) | ||
278 | { | ||
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
280 | "%d:Wrong type reference to %s at %s\n", | ||
281 | i, | ||
282 | cmd[i].details.load_array.label_save, | ||
283 | cmd[i].label); | ||
284 | return GNUNET_SYSERR; | ||
285 | } | ||
286 | cmd[i].details.load_array.index_save = ret; | ||
287 | |||
288 | ret = cmd_find (cmd, | ||
289 | cmd[i].details.load_array.label_loop); | ||
290 | if (GNUNET_SYSERR == ret) | ||
291 | { | ||
292 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
293 | "%d:Undefined reference to %s\n", | ||
294 | i, | ||
295 | cmd[i].details.load_array.label_loop); | ||
296 | return GNUNET_SYSERR; | ||
297 | } | ||
298 | if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) | ||
299 | { | ||
300 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
301 | "%d:Wrong type reference to %s\n", | ||
302 | i, | ||
303 | cmd[i].details.load_array.label_loop); | ||
304 | return GNUNET_SYSERR; | ||
305 | } | ||
306 | cmd[i].details.load_array.index_loop = ret; | ||
307 | |||
308 | cmd[i].details.load_array.permutation = | ||
309 | GNUNET_CRYPTO_random_permute ( | ||
310 | GNUNET_CRYPTO_QUALITY_WEAK, | ||
311 | cmd[cmd[i].details.load_array.index_save].details.save_array. | ||
312 | nb_saved); | ||
313 | GNUNET_assert (NULL != cmd[i].details.load_array.permutation); | ||
314 | |||
315 | cmd[i].exposed.type = | ||
316 | cmd[cmd[i].details.load_array.index_save].details.save_array. | ||
317 | type_saved; | ||
318 | } | ||
319 | break; | ||
320 | |||
321 | case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: | ||
322 | { | ||
323 | int ret; | ||
324 | |||
325 | ret = cmd_find (cmd, | ||
326 | cmd[i].details.load_random.label_save); | ||
327 | if (GNUNET_SYSERR == ret) | ||
328 | { | ||
329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
330 | "%d:Undefined reference to %s\n", | ||
331 | i, | ||
332 | cmd[i].details.load_random.label_save); | ||
333 | return GNUNET_SYSERR; | ||
334 | } | ||
335 | if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) | ||
336 | { | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
338 | "%d:Wrong type reference to %s\n", | ||
339 | i, | ||
340 | cmd[i].details.load_random.label_save); | ||
341 | return GNUNET_SYSERR; | ||
342 | } | ||
343 | cmd[i].details.load_random.index_save = ret; | ||
344 | } | ||
345 | break; | ||
346 | |||
347 | case PERF_TALER_EXCHANGEDB_CMD_GAUGER: | ||
348 | { | ||
349 | int ret; | ||
350 | |||
351 | ret = cmd_find (cmd, | ||
352 | cmd[i].details.gauger.label_start); | ||
353 | if (GNUNET_SYSERR == ret) | ||
354 | { | ||
355 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
356 | "%d:Undefined reference to %s\n", | ||
357 | i, | ||
358 | cmd[i].details.gauger.label_start); | ||
359 | return GNUNET_SYSERR; | ||
360 | } | ||
361 | if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) | ||
362 | { | ||
363 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
364 | "%d:Wrong type reference to %s\n", | ||
365 | i, | ||
366 | cmd[i].details.gauger.label_start); | ||
367 | return GNUNET_SYSERR; | ||
368 | } | ||
369 | cmd[i].details.gauger.index_start = ret; | ||
370 | |||
371 | ret = cmd_find (cmd, | ||
372 | cmd[i].details.gauger.label_stop); | ||
373 | if (GNUNET_SYSERR == ret) | ||
374 | { | ||
375 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
376 | "%d:Undefined reference to %s\n", | ||
377 | i, | ||
378 | cmd[i].details.gauger.label_stop); | ||
379 | return GNUNET_SYSERR; | ||
380 | } | ||
381 | if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) | ||
382 | { | ||
383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
384 | "%d:Wrong type reference to %s\n", | ||
385 | i, | ||
386 | cmd[i].details.gauger.label_stop); | ||
387 | return GNUNET_SYSERR; | ||
388 | } | ||
389 | cmd[i].details.gauger.index_stop = ret; | ||
390 | } | ||
391 | break; | ||
392 | |||
393 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: | ||
394 | { | ||
395 | int ret; | ||
396 | |||
397 | ret = cmd_find (cmd, | ||
398 | cmd[i].details.insert_denomination.label_denom); | ||
399 | if (GNUNET_SYSERR == ret) | ||
400 | { | ||
401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
402 | "%d:Undefined reference to %s\n", | ||
403 | i, | ||
404 | cmd[i].details.insert_denomination.label_denom); | ||
405 | return GNUNET_SYSERR; | ||
406 | } | ||
407 | if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) | ||
408 | { | ||
409 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
410 | "%d:Wrong type reference to %s\n", | ||
411 | i, | ||
412 | cmd[i].details.insert_denomination.label_denom); | ||
413 | return GNUNET_SYSERR; | ||
414 | } | ||
415 | cmd[i].details.insert_denomination.index_denom = ret; | ||
416 | } | ||
417 | break; | ||
418 | |||
419 | case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: | ||
420 | { | ||
421 | int ret; | ||
422 | |||
423 | ret = cmd_find (cmd, | ||
424 | cmd[i].details.get_denomination.label_denom); | ||
425 | if (GNUNET_SYSERR == ret) | ||
426 | { | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
428 | "%d:Undefined reference to %s\n", | ||
429 | i, | ||
430 | cmd[i].details.get_denomination.label_denom); | ||
431 | return GNUNET_SYSERR; | ||
432 | } | ||
433 | if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) | ||
434 | { | ||
435 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
436 | "%d:Wrong type reference to %s\n", | ||
437 | i, | ||
438 | cmd[i].details.get_denomination.label_denom); | ||
439 | return GNUNET_SYSERR; | ||
440 | } | ||
441 | cmd[i].details.get_denomination.index_denom = ret; | ||
442 | } | ||
443 | break; | ||
444 | |||
445 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: | ||
446 | { | ||
447 | int ret; | ||
448 | |||
449 | ret = cmd_find (cmd, | ||
450 | cmd[i].details.insert_reserve.label_reserve); | ||
451 | if (GNUNET_SYSERR == ret) | ||
452 | { | ||
453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
454 | "%d:Undefined reference to %s\n", | ||
455 | i, | ||
456 | cmd[i].details.insert_reserve.label_reserve); | ||
457 | return GNUNET_SYSERR; | ||
458 | } | ||
459 | if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) | ||
460 | { | ||
461 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
462 | "%d:Wrong type reference to %s\n", | ||
463 | i, | ||
464 | cmd[i].details.insert_reserve.label_reserve); | ||
465 | return GNUNET_SYSERR; | ||
466 | } | ||
467 | cmd[i].details.insert_reserve.index_reserve = ret; | ||
468 | } | ||
469 | break; | ||
470 | |||
471 | case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: | ||
472 | { | ||
473 | int ret; | ||
474 | |||
475 | ret = cmd_find (cmd, | ||
476 | cmd[i].details.get_reserve.label_reserve); | ||
477 | if (GNUNET_SYSERR == ret) | ||
478 | { | ||
479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
480 | "%d:Undefined reference to %s\n", | ||
481 | i, | ||
482 | cmd[i].details.get_reserve.label_reserve); | ||
483 | return GNUNET_SYSERR; | ||
484 | } | ||
485 | if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) | ||
486 | { | ||
487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
488 | "%d:Wrong type reference to %s\n", | ||
489 | i, | ||
490 | cmd[i].details.get_reserve.label_reserve); | ||
491 | return GNUNET_SYSERR; | ||
492 | } | ||
493 | cmd[i].details.get_reserve.index_reserve = ret; | ||
494 | } | ||
495 | break; | ||
496 | |||
497 | case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: | ||
498 | { | ||
499 | int ret; | ||
500 | |||
501 | ret = cmd_find (cmd, | ||
502 | cmd[i].details.get_reserve_history.label_reserve); | ||
503 | if (GNUNET_SYSERR == ret) | ||
504 | { | ||
505 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
506 | "%d:Undefined reference to %s\n", | ||
507 | i, | ||
508 | cmd[i].details.get_reserve_history.label_reserve); | ||
509 | return GNUNET_SYSERR; | ||
510 | } | ||
511 | if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) | ||
512 | { | ||
513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
514 | "%d:Wrong type reference to %s\n", | ||
515 | i, | ||
516 | cmd[i].details.get_reserve_history.label_reserve); | ||
517 | return GNUNET_SYSERR; | ||
518 | } | ||
519 | cmd[i].details.get_reserve_history.index_reserve = ret; | ||
520 | } | ||
521 | break; | ||
522 | |||
523 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: | ||
524 | { | ||
525 | int ret; | ||
526 | |||
527 | ret = cmd_find (cmd, | ||
528 | cmd[i].details.create_withdraw.label_dki); | ||
529 | { | ||
530 | if (GNUNET_SYSERR == ret) | ||
531 | { | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | "%d:Undefined reference to %s\n", | ||
534 | i, | ||
535 | cmd[i].details.create_withdraw.label_dki); | ||
536 | return GNUNET_SYSERR; | ||
537 | } | ||
538 | if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) | ||
539 | { | ||
540 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
541 | "%d:Wrong type reference to %s\n", | ||
542 | i, | ||
543 | cmd[i].details.create_withdraw.label_dki); | ||
544 | return GNUNET_SYSERR; | ||
545 | } | ||
546 | } | ||
547 | cmd[i].details.create_withdraw.index_dki = ret; | ||
548 | ret = cmd_find (cmd, | ||
549 | cmd[i].details.create_withdraw.label_reserve); | ||
550 | { | ||
551 | if (GNUNET_SYSERR == ret) | ||
552 | { | ||
553 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
554 | "%d:Undefined reference to %s\n", | ||
555 | i, | ||
556 | cmd[i].details.create_withdraw.label_reserve); | ||
557 | return GNUNET_SYSERR; | ||
558 | } | ||
559 | if (PERF_TALER_EXCHANGEDB_RESERVE != cmd[ret].exposed.type) | ||
560 | { | ||
561 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
562 | "%d:Wrong type reference to %s\n", | ||
563 | i, | ||
564 | cmd[i].details.create_withdraw.label_reserve); | ||
565 | return GNUNET_SYSERR; | ||
566 | } | ||
567 | } | ||
568 | cmd[i].details.create_withdraw.index_reserve = ret; | ||
569 | } | ||
570 | break; | ||
571 | |||
572 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: | ||
573 | { | ||
574 | int ret; | ||
575 | |||
576 | ret = cmd_find (cmd, | ||
577 | cmd[i].details.insert_withdraw.label_coin); | ||
578 | if (GNUNET_SYSERR == ret) | ||
579 | { | ||
580 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
581 | "%d:Undefined reference to %s\n", | ||
582 | i, | ||
583 | cmd[i].details.insert_withdraw.label_coin); | ||
584 | return GNUNET_SYSERR; | ||
585 | } | ||
586 | if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) | ||
587 | { | ||
588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
589 | "%d:Wrong type reference to %s\n", | ||
590 | i, | ||
591 | cmd[i].details.insert_withdraw.label_coin); | ||
592 | return GNUNET_SYSERR; | ||
593 | } | ||
594 | cmd[i].details.insert_withdraw.index_coin = ret; | ||
595 | } | ||
596 | break; | ||
597 | |||
598 | case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: | ||
599 | { | ||
600 | int ret; | ||
601 | |||
602 | ret = cmd_find (cmd, | ||
603 | cmd[i].details.get_withdraw.label_coin); | ||
604 | if (GNUNET_SYSERR == ret) | ||
605 | { | ||
606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
607 | "%d:Undefined reference to %s\n", | ||
608 | i, | ||
609 | cmd[i].details.get_withdraw.label_coin); | ||
610 | return GNUNET_SYSERR; | ||
611 | } | ||
612 | if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) | ||
613 | { | ||
614 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
615 | "%d:Wrong type reference to %s\n", | ||
616 | i, | ||
617 | cmd[i].details.get_withdraw.label_coin); | ||
618 | return GNUNET_SYSERR; | ||
619 | } | ||
620 | cmd[i].details.get_withdraw.index_coin = ret; | ||
621 | } | ||
622 | break; | ||
623 | |||
624 | case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: | ||
625 | { | ||
626 | int ret; | ||
627 | ret = cmd_find (cmd, | ||
628 | cmd[i].details.get_coin_transaction.label_coin); | ||
629 | if (GNUNET_SYSERR == ret) | ||
630 | { | ||
631 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
632 | "%d:Undefined reference to %s\n", | ||
633 | i, | ||
634 | cmd[i].details.get_coin_transaction.label_coin); | ||
635 | return GNUNET_SYSERR; | ||
636 | } | ||
637 | if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) | ||
638 | { | ||
639 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
640 | "%d:Wrong type reference to %s\n", | ||
641 | i, | ||
642 | cmd[i].details.get_coin_transaction.label_coin); | ||
643 | return GNUNET_SYSERR; | ||
644 | } | ||
645 | cmd[i].details.get_coin_transaction.index_coin = ret; | ||
646 | } | ||
647 | break; | ||
648 | |||
649 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: | ||
650 | { | ||
651 | int ret; | ||
652 | |||
653 | ret = cmd_find (cmd, | ||
654 | cmd[i].details.create_deposit.label_coin); | ||
655 | if (GNUNET_SYSERR == ret) | ||
656 | { | ||
657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
658 | "%d:Undefined reference to %s\n", | ||
659 | i, | ||
660 | cmd[i].details.create_deposit.label_coin); | ||
661 | return GNUNET_SYSERR; | ||
662 | } | ||
663 | if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) | ||
664 | { | ||
665 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
666 | "%d:Wrong type reference to %s\n", | ||
667 | i, | ||
668 | cmd[i].details.create_deposit.label_coin); | ||
669 | return GNUNET_SYSERR; | ||
670 | } | ||
671 | cmd[i].details.create_deposit.index_coin = ret; | ||
672 | } | ||
673 | break; | ||
674 | |||
675 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: | ||
676 | { | ||
677 | int ret; | ||
678 | |||
679 | ret = cmd_find (cmd, | ||
680 | cmd[i].details.insert_deposit.label_deposit); | ||
681 | if (GNUNET_SYSERR == ret) | ||
682 | { | ||
683 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
684 | "%d:Undefined reference to %s\n", | ||
685 | i, | ||
686 | cmd[i].details.insert_deposit.label_deposit); | ||
687 | return GNUNET_SYSERR; | ||
688 | } | ||
689 | if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) | ||
690 | { | ||
691 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
692 | "%d:Wrong type reference to %s\n", | ||
693 | i, | ||
694 | cmd[i].details.insert_deposit.label_deposit); | ||
695 | return GNUNET_SYSERR; | ||
696 | } | ||
697 | cmd[i].details.insert_deposit.index_deposit = ret; | ||
698 | } | ||
699 | break; | ||
700 | |||
701 | case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: | ||
702 | { | ||
703 | int ret; | ||
704 | |||
705 | ret = cmd_find (cmd, | ||
706 | cmd[i].details.get_deposit.label_deposit); | ||
707 | if (GNUNET_SYSERR == ret) | ||
708 | { | ||
709 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
710 | "%d:Undefined reference to %s\n", | ||
711 | i, | ||
712 | cmd[i].details.get_deposit.label_deposit); | ||
713 | return GNUNET_SYSERR; | ||
714 | } | ||
715 | if (PERF_TALER_EXCHANGEDB_DEPOSIT != cmd[ret].exposed.type) | ||
716 | { | ||
717 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
718 | "%d:Wrong type reference to %s\n", | ||
719 | i, | ||
720 | cmd[i].details.get_deposit.label_deposit); | ||
721 | return GNUNET_SYSERR; | ||
722 | } | ||
723 | cmd[i].details.get_deposit.index_deposit = ret; | ||
724 | } | ||
725 | break; | ||
726 | |||
727 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: | ||
728 | { | ||
729 | int ret; | ||
730 | |||
731 | ret = cmd_find (cmd, | ||
732 | cmd[i].details.create_refresh_session.label_coin); | ||
733 | if (GNUNET_SYSERR == ret) | ||
734 | { | ||
735 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
736 | "%d:Undefined reference to %s at %s\n", | ||
737 | i, | ||
738 | cmd[i].details.create_refresh_session.label_coin, | ||
739 | cmd[i].label); | ||
740 | return GNUNET_SYSERR; | ||
741 | } | ||
742 | if (PERF_TALER_EXCHANGEDB_COIN != cmd[ret].exposed.type) | ||
743 | { | ||
744 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
745 | "%d:Wrong type reference to %s at %s\n", | ||
746 | i, | ||
747 | cmd[i].details.create_refresh_session.label_coin, | ||
748 | cmd[i].label); | ||
749 | return GNUNET_SYSERR; | ||
750 | } | ||
751 | cmd[i].details.create_refresh_session.index_coin = ret; | ||
752 | } | ||
753 | break; | ||
754 | |||
755 | case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: | ||
756 | { | ||
757 | int ret; | ||
758 | |||
759 | ret = cmd_find (cmd, | ||
760 | cmd[i].details.get_refresh_session.label_hash); | ||
761 | if (GNUNET_SYSERR == ret) | ||
762 | { | ||
763 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
764 | "%d:Undefined reference to %s at %s\n", | ||
765 | i, | ||
766 | cmd[i].details.get_refresh_session.label_hash, | ||
767 | cmd[i].label); | ||
768 | return GNUNET_SYSERR; | ||
769 | } | ||
770 | if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) | ||
771 | { | ||
772 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
773 | "%d:Wrong type reference to %s at %s\n", | ||
774 | i, | ||
775 | cmd[i].details.get_refresh_session.label_hash, | ||
776 | cmd[i].label); | ||
777 | return GNUNET_SYSERR; | ||
778 | } | ||
779 | cmd[i].details.get_refresh_session.index_hash = ret; | ||
780 | } | ||
781 | break; | ||
782 | |||
783 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: | ||
784 | { | ||
785 | int ret; | ||
786 | ret = cmd_find (cmd, | ||
787 | cmd[i].details.insert_refresh_reveal.label_hash); | ||
788 | if (GNUNET_SYSERR == ret) | ||
789 | { | ||
790 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
791 | "%d:Undefined reference to %s\n", | ||
792 | i, | ||
793 | cmd[i].details.insert_refresh_reveal.label_hash); | ||
794 | return GNUNET_SYSERR; | ||
795 | } | ||
796 | if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) | ||
797 | { | ||
798 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
799 | "%d:Wrong type reference to %s\n", | ||
800 | i, | ||
801 | cmd[i].details.insert_refresh_reveal.label_hash); | ||
802 | return GNUNET_SYSERR; | ||
803 | } | ||
804 | cmd[i].details.insert_refresh_reveal.index_hash = ret; | ||
805 | |||
806 | ret = cmd_find (cmd, | ||
807 | cmd[i].details.insert_refresh_reveal.label_denom); | ||
808 | if (GNUNET_SYSERR == ret) | ||
809 | { | ||
810 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
811 | "%d:Undefined reference to %s\n", | ||
812 | i, | ||
813 | cmd[i].details.insert_refresh_reveal.label_denom); | ||
814 | return GNUNET_SYSERR; | ||
815 | } | ||
816 | if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) | ||
817 | { | ||
818 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
819 | "%d:Wrong type reference to %s\n", | ||
820 | i, | ||
821 | cmd[i].details.insert_refresh_reveal.label_denom); | ||
822 | return GNUNET_SYSERR; | ||
823 | } | ||
824 | cmd[i].details.insert_refresh_reveal.index_denom = ret; | ||
825 | } | ||
826 | break; | ||
827 | |||
828 | case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: | ||
829 | { | ||
830 | int ret; | ||
831 | ret = cmd_find (cmd, | ||
832 | cmd[i].details.get_refresh_reveal.label_hash); | ||
833 | if (GNUNET_SYSERR == ret) | ||
834 | { | ||
835 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
836 | "%d:Undefined reference to %s\n", | ||
837 | i, | ||
838 | cmd[i].details.get_refresh_reveal.label_hash); | ||
839 | return GNUNET_SYSERR; | ||
840 | } | ||
841 | if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) | ||
842 | { | ||
843 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
844 | "%d:Wrong type reference to %s\n", | ||
845 | i, | ||
846 | cmd[i].details.get_refresh_reveal.label_hash); | ||
847 | return GNUNET_SYSERR; | ||
848 | } | ||
849 | cmd[i].details.get_refresh_reveal.index_hash = ret; | ||
850 | } | ||
851 | break; | ||
852 | |||
853 | case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: | ||
854 | { | ||
855 | int ret; | ||
856 | ret = cmd_find (cmd, | ||
857 | cmd[i].details.get_link_data_list.label_hash); | ||
858 | if (GNUNET_SYSERR == ret) | ||
859 | { | ||
860 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
861 | "%d:Undefined reference to %s\n", | ||
862 | i, | ||
863 | cmd[i].details.get_link_data_list.label_hash); | ||
864 | return GNUNET_SYSERR; | ||
865 | } | ||
866 | if (PERF_TALER_EXCHANGEDB_REFRESH_HASH != cmd[ret].exposed.type) | ||
867 | { | ||
868 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
869 | "%d:Wrong type reference to %s\n", | ||
870 | i, | ||
871 | cmd[i].details.get_link_data_list.label_hash); | ||
872 | return GNUNET_SYSERR; | ||
873 | } | ||
874 | cmd[i].details.get_link_data_list.index_hash = ret; | ||
875 | } | ||
876 | break; | ||
877 | |||
878 | case PERF_TALER_EXCHANGEDB_CMD_END: | ||
879 | case PERF_TALER_EXCHANGEDB_CMD_DEBUG: | ||
880 | case PERF_TALER_EXCHANGEDB_CMD_LOOP: | ||
881 | case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: | ||
882 | case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: | ||
883 | case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: | ||
884 | case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: | ||
885 | case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: | ||
886 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: | ||
887 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: | ||
888 | break; | ||
889 | } | ||
890 | } | ||
891 | return GNUNET_OK; | ||
892 | } | ||
893 | |||
894 | |||
895 | /** | ||
896 | * Free the memory of the command chain | ||
897 | */ | ||
898 | static int | ||
899 | cmd_clean (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) | ||
900 | { | ||
901 | for (unsigned int i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) | ||
902 | { | ||
903 | switch (cmd[i].command) | ||
904 | { | ||
905 | case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: | ||
906 | { | ||
907 | for (unsigned int j = 0; j < cmd[i].details.save_array.nb_saved; j++) | ||
908 | { | ||
909 | data_free (&cmd[i].details.save_array.data_saved[j]); | ||
910 | } | ||
911 | GNUNET_free (cmd[i].details.save_array.data_saved); | ||
912 | cmd[i].details.save_array.data_saved = NULL; | ||
913 | } | ||
914 | break; | ||
915 | |||
916 | case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: | ||
917 | GNUNET_free (cmd[i].details.load_array.permutation); | ||
918 | cmd[i].details.load_array.permutation = NULL; | ||
919 | break; | ||
920 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: | ||
921 | PERF_TALER_EXCHANGEDB_coin_free (cmd[i].exposed.data.coin); | ||
922 | break; | ||
923 | default: | ||
924 | break; | ||
925 | } | ||
926 | data_free (&cmd[i].exposed); | ||
927 | } | ||
928 | return GNUNET_OK; | ||
929 | } | ||
930 | |||
931 | |||
932 | /** | ||
933 | * Handles the command #PERF_TALER_EXCHANGEDB_CMD_END_LOOP for the interpreter | ||
934 | * Cleans the memory at the end of the loop | ||
935 | */ | ||
936 | static void | ||
937 | interpret_end_loop (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) | ||
938 | { | ||
939 | int jump; | ||
940 | |||
941 | jump = state->cmd[state->i].details.end_loop.index_loop; | ||
942 | // Cleaning up the memory in the loop | ||
943 | for (unsigned int i = jump; i < state->i; i++) | ||
944 | data_free (&state->cmd[i].exposed); | ||
945 | |||
946 | state->cmd[jump].details.loop.curr_iteration++; | ||
947 | /* If the loop is not finished */ | ||
948 | if (state->cmd[jump].details.loop.max_iterations > | ||
949 | state->cmd[jump].details.loop.curr_iteration) | ||
950 | { | ||
951 | /* jump back to the start */ | ||
952 | state->i = jump; | ||
953 | } | ||
954 | else | ||
955 | { | ||
956 | /* Reset the loop counter and continue running */ | ||
957 | state->cmd[jump].details.loop.curr_iteration = 0; | ||
958 | } | ||
959 | } | ||
960 | |||
961 | |||
962 | /** | ||
963 | * Part of the interpreter specific to | ||
964 | * #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY | ||
965 | * Saves the data exposed by another command into | ||
966 | * an array in the command specific struct. | ||
967 | */ | ||
968 | static void | ||
969 | interpret_save_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) | ||
970 | { | ||
971 | struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i]; | ||
972 | struct PERF_TALER_EXCHANGEDB_Cmd *save_ref; | ||
973 | struct PERF_TALER_EXCHANGEDB_Cmd *loop_ref; | ||
974 | int loop_index; | ||
975 | int save_index; | ||
976 | unsigned int selection_chance; | ||
977 | |||
978 | loop_index = cmd->details.save_array.index_loop; | ||
979 | save_index = cmd->details.save_array.index_save; | ||
980 | loop_ref = &state->cmd[loop_index]; | ||
981 | save_ref = &state->cmd[save_index]; | ||
982 | /* Array initialization on first loop iteration | ||
983 | Alows for nested loops */ | ||
984 | if (0 == cmd->details.loop.curr_iteration) | ||
985 | { | ||
986 | cmd->details.save_array.index = 0; | ||
987 | } | ||
988 | /* The probability distribution of the saved items will be a little biased | ||
989 | against the few last items but it should not be a big problem. */ | ||
990 | selection_chance = loop_ref->details.loop.max_iterations | ||
991 | / cmd->details.save_array.nb_saved; | ||
992 | /* | ||
993 | * If the remaining space is equal to the remaining number of | ||
994 | * iterations, the item is automaticly saved. | ||
995 | * | ||
996 | * Else it is saved only if the random numbre generated is 0 | ||
997 | */ | ||
998 | if ( (0 < (cmd->details.save_array.nb_saved | ||
999 | - cmd->details.save_array.index) ) && | ||
1000 | ( ((loop_ref->details.loop.max_iterations | ||
1001 | - loop_ref->details.loop.curr_iteration) == | ||
1002 | (cmd->details.save_array.nb_saved | ||
1003 | - cmd->details.save_array.index)) || | ||
1004 | (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1005 | selection_chance)) ) ) | ||
1006 | { | ||
1007 | struct PERF_TALER_EXCHANGEDB_Data *save_location; | ||
1008 | struct PERF_TALER_EXCHANGEDB_Data *item_saved; | ||
1009 | |||
1010 | save_location = | ||
1011 | &cmd->details.save_array.data_saved[cmd->details.save_array.index]; | ||
1012 | item_saved = &save_ref->exposed; | ||
1013 | data_copy (item_saved, save_location); | ||
1014 | cmd->details.save_array.index++; | ||
1015 | } | ||
1016 | } | ||
1017 | |||
1018 | |||
1019 | /** | ||
1020 | * Part of the interpreter specific to | ||
1021 | * #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY | ||
1022 | * Gets data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY and exposes a copy | ||
1023 | */ | ||
1024 | static void | ||
1025 | interpret_load_array (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) | ||
1026 | { | ||
1027 | struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i]; | ||
1028 | unsigned int loop_iter; | ||
1029 | int loop_index; | ||
1030 | int save_index; | ||
1031 | struct PERF_TALER_EXCHANGEDB_Data *loaded_data; | ||
1032 | |||
1033 | loop_index = cmd->details.load_array.index_loop; | ||
1034 | save_index = cmd->details.load_array.index_save; | ||
1035 | loop_iter = state->cmd[loop_index].details.loop.curr_iteration; | ||
1036 | { | ||
1037 | unsigned int i; | ||
1038 | unsigned int quotient; | ||
1039 | |||
1040 | /* In case the iteration number is higher than the amount saved, | ||
1041 | * the number is run several times in the permutation array */ | ||
1042 | quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved; | ||
1043 | loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved; | ||
1044 | for (i = 0; i<=quotient; i++) | ||
1045 | loop_iter = cmd->details.load_array.permutation[loop_iter]; | ||
1046 | } | ||
1047 | /* Extracting the data from the loop_indexth indice in save_index | ||
1048 | * array. | ||
1049 | */ | ||
1050 | loaded_data = | ||
1051 | &state->cmd[save_index].details.save_array.data_saved[loop_iter]; | ||
1052 | data_copy (loaded_data, | ||
1053 | &cmd->exposed); | ||
1054 | } | ||
1055 | |||
1056 | |||
1057 | /** | ||
1058 | * Part of the interpreter specific to | ||
1059 | * #PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM | ||
1060 | * Get a random element from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY and exposes it | ||
1061 | */ | ||
1062 | static void | ||
1063 | interprete_load_random (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) | ||
1064 | { | ||
1065 | struct PERF_TALER_EXCHANGEDB_Cmd *cmd = &state->cmd[state->i]; | ||
1066 | unsigned int index; | ||
1067 | int save_index; | ||
1068 | |||
1069 | save_index = cmd->details.load_random.index_save; | ||
1070 | index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1071 | state->cmd[save_index].details.save_array. | ||
1072 | nb_saved); | ||
1073 | data_copy (&state->cmd[save_index].details.save_array.data_saved[index], | ||
1074 | &cmd->exposed); | ||
1075 | } | ||
1076 | |||
1077 | |||
1078 | /** | ||
1079 | * Function called with information about a refresh order. | ||
1080 | * | ||
1081 | * @param cls closure | ||
1082 | * @param rowid unique serial ID for the row in our database | ||
1083 | * @param num_newcoins size of the @a rrcs array | ||
1084 | * @param rrcs array of @a num_newcoins information about coins to be created | ||
1085 | * @param num_tprivs number of entries in @a tprivs, should be #TALER_CNC_KAPPA - 1 | ||
1086 | * @param tprivs array of @e num_tprivs transfer private keys | ||
1087 | * @param tp transfer public key information | ||
1088 | */ | ||
1089 | static void | ||
1090 | refresh_reveal_cb (void *cls, | ||
1091 | uint32_t num_newcoins, | ||
1092 | const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, | ||
1093 | unsigned int num_tprivs, | ||
1094 | const struct TALER_TransferPrivateKeyP *tprivs, | ||
1095 | const struct TALER_TransferPublicKeyP *tp) | ||
1096 | { | ||
1097 | /* intentionally empty */ | ||
1098 | } | ||
1099 | |||
1100 | |||
1101 | /** | ||
1102 | * Iterate over the commands, acting accordingly at each step | ||
1103 | * | ||
1104 | * @param state the current state of the interpreter | ||
1105 | */ | ||
1106 | static int | ||
1107 | interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) | ||
1108 | { | ||
1109 | for (state->i = 0; PERF_TALER_EXCHANGEDB_CMD_END != | ||
1110 | state->cmd[state->i].command; state->i++) | ||
1111 | { | ||
1112 | switch (state->cmd[state->i].command) | ||
1113 | { | ||
1114 | case PERF_TALER_EXCHANGEDB_CMD_END: | ||
1115 | return GNUNET_YES; | ||
1116 | |||
1117 | case PERF_TALER_EXCHANGEDB_CMD_DEBUG: | ||
1118 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1119 | "%s\n", | ||
1120 | state->cmd[state->i].label); | ||
1121 | break; | ||
1122 | |||
1123 | case PERF_TALER_EXCHANGEDB_CMD_LOOP: | ||
1124 | break; | ||
1125 | |||
1126 | case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: | ||
1127 | interpret_end_loop (state); | ||
1128 | break; | ||
1129 | |||
1130 | case PERF_TALER_EXCHANGEDB_CMD_GET_TIME: | ||
1131 | state->cmd[state->i].exposed.data.time = | ||
1132 | GNUNET_new (struct GNUNET_TIME_Absolute); | ||
1133 | *state->cmd[state->i].exposed.data.time = | ||
1134 | GNUNET_TIME_absolute_get (); | ||
1135 | break; | ||
1136 | |||
1137 | case PERF_TALER_EXCHANGEDB_CMD_GAUGER: | ||
1138 | { | ||
1139 | unsigned int start_index; | ||
1140 | unsigned int stop_index; | ||
1141 | float ips; | ||
1142 | struct GNUNET_TIME_Absolute start; | ||
1143 | struct GNUNET_TIME_Absolute stop; | ||
1144 | struct GNUNET_TIME_Relative elapsed; | ||
1145 | |||
1146 | start_index = state->cmd[state->i].details.gauger.index_start; | ||
1147 | stop_index = state->cmd[state->i].details.gauger.index_stop; | ||
1148 | start = *state->cmd[start_index].exposed.data.time; | ||
1149 | stop = *state->cmd[stop_index].exposed.data.time; | ||
1150 | elapsed = GNUNET_TIME_absolute_get_difference (start, | ||
1151 | stop); | ||
1152 | ips = (1.0 * state->cmd[state->i].details.gauger.divide) | ||
1153 | / (elapsed.rel_value_us / 1000000.0); | ||
1154 | GAUGER (state->cmd[state->i].details.gauger.category, | ||
1155 | state->cmd[state->i].details.gauger.description, | ||
1156 | ips, | ||
1157 | state->cmd[state->i].details.gauger.unit); | ||
1158 | } | ||
1159 | break; | ||
1160 | |||
1161 | case PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION: | ||
1162 | state->session = state->plugin->get_session (state->plugin->cls); | ||
1163 | break; | ||
1164 | |||
1165 | case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION: | ||
1166 | GNUNET_break (GNUNET_OK == | ||
1167 | state->plugin->start (state->plugin->cls, | ||
1168 | state->session, | ||
1169 | "perf-interpreter")); | ||
1170 | break; | ||
1171 | |||
1172 | case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION: | ||
1173 | GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == | ||
1174 | state->plugin->commit (state->plugin->cls, | ||
1175 | state->session)); | ||
1176 | break; | ||
1177 | case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION: | ||
1178 | state->plugin->rollback (state->plugin->cls, | ||
1179 | state->session); | ||
1180 | break; | ||
1181 | |||
1182 | case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: | ||
1183 | interpret_save_array (state); | ||
1184 | break; | ||
1185 | |||
1186 | case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: | ||
1187 | interpret_load_array (state); | ||
1188 | break; | ||
1189 | |||
1190 | case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: | ||
1191 | interprete_load_random (state); | ||
1192 | break; | ||
1193 | |||
1194 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT: | ||
1195 | { | ||
1196 | int coin_index; | ||
1197 | struct TALER_EXCHANGEDB_Deposit *deposit; | ||
1198 | |||
1199 | coin_index = state->cmd[state->i].details.create_deposit.index_coin; | ||
1200 | deposit = PERF_TALER_EXCHANGEDB_deposit_init ( | ||
1201 | state->cmd[coin_index].exposed.data.coin); | ||
1202 | GNUNET_assert (NULL != deposit); | ||
1203 | state->cmd[state->i].exposed.data.deposit = deposit; | ||
1204 | } | ||
1205 | break; | ||
1206 | |||
1207 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT: | ||
1208 | { | ||
1209 | int deposit_index; | ||
1210 | enum GNUNET_DB_QueryStatus qs; | ||
1211 | struct TALER_EXCHANGEDB_Deposit *deposit; | ||
1212 | |||
1213 | deposit_index = | ||
1214 | state->cmd[state->i].details.insert_deposit.index_deposit; | ||
1215 | deposit = state->cmd[deposit_index].exposed.data.deposit; | ||
1216 | qs = state->plugin->ensure_coin_known (state->plugin->cls, | ||
1217 | state->session, | ||
1218 | &deposit->coin); | ||
1219 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1220 | qs = state->plugin->insert_deposit (state->plugin->cls, | ||
1221 | state->session, | ||
1222 | deposit); | ||
1223 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1224 | state->cmd[state->i].exposed.data.deposit | ||
1225 | = PERF_TALER_EXCHANGEDB_deposit_copy (deposit); | ||
1226 | } | ||
1227 | break; | ||
1228 | |||
1229 | case PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT: | ||
1230 | { | ||
1231 | unsigned int source_index; | ||
1232 | enum GNUNET_DB_QueryStatus ret; | ||
1233 | struct PERF_TALER_EXCHANGEDB_Data *data; | ||
1234 | |||
1235 | source_index = state->cmd[state->i].details.get_deposit.index_deposit; | ||
1236 | data = &state->cmd[source_index].exposed; | ||
1237 | ret = state->plugin->have_deposit (state->plugin->cls, | ||
1238 | state->session, | ||
1239 | data->data.deposit, | ||
1240 | GNUNET_YES); | ||
1241 | GNUNET_assert (0 >= ret); | ||
1242 | } | ||
1243 | break; | ||
1244 | |||
1245 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE: | ||
1246 | { | ||
1247 | struct PERF_TALER_EXCHANGEDB_Reserve *reserve; | ||
1248 | |||
1249 | reserve = PERF_TALER_EXCHANGEDB_reserve_init (); | ||
1250 | state->cmd[state->i].exposed.data.reserve = reserve; | ||
1251 | } | ||
1252 | break; | ||
1253 | |||
1254 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE: | ||
1255 | { | ||
1256 | unsigned int reserve_index; | ||
1257 | int ret; | ||
1258 | struct PERF_TALER_EXCHANGEDB_Reserve *reserve; | ||
1259 | char *sndr; | ||
1260 | uint32_t uid; | ||
1261 | struct GNUNET_TIME_Absolute now; | ||
1262 | |||
1263 | reserve_index = | ||
1264 | state->cmd[state->i].details.insert_reserve.index_reserve; | ||
1265 | reserve = state->cmd[reserve_index].exposed.data.reserve; | ||
1266 | GNUNET_asprintf (&sndr, | ||
1267 | "payto://x-taler-test/localhost:8080/%u", | ||
1268 | (unsigned int) GNUNET_CRYPTO_random_u32 ( | ||
1269 | GNUNET_CRYPTO_QUALITY_WEAK, | ||
1270 | UINT32_MAX)); | ||
1271 | uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1272 | UINT32_MAX); | ||
1273 | now = GNUNET_TIME_absolute_get (); | ||
1274 | (void) GNUNET_TIME_round_abs (&now); | ||
1275 | ret = state->plugin->reserves_in_insert (state->plugin->cls, | ||
1276 | state->session, | ||
1277 | &reserve->reserve.pub, | ||
1278 | &reserve->reserve.balance, | ||
1279 | now, | ||
1280 | sndr, | ||
1281 | "account-1", | ||
1282 | &uid, | ||
1283 | sizeof (uid)); | ||
1284 | GNUNET_assert (GNUNET_SYSERR != ret); | ||
1285 | GNUNET_free (sndr); | ||
1286 | } | ||
1287 | break; | ||
1288 | |||
1289 | case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE: | ||
1290 | { | ||
1291 | unsigned int reserve_index; | ||
1292 | int ret; | ||
1293 | struct PERF_TALER_EXCHANGEDB_Data *data; | ||
1294 | |||
1295 | |||
1296 | reserve_index = state->cmd[state->i].details.get_reserve.index_reserve; | ||
1297 | data = &state->cmd[reserve_index].exposed; | ||
1298 | ret = state->plugin->reserve_get (state->plugin->cls, | ||
1299 | state->session, | ||
1300 | &data->data.reserve->reserve); | ||
1301 | GNUNET_assert (GNUNET_OK == ret); | ||
1302 | } | ||
1303 | break; | ||
1304 | |||
1305 | case PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY: | ||
1306 | { | ||
1307 | unsigned int reserve_index; | ||
1308 | struct TALER_EXCHANGEDB_ReserveHistory *history; | ||
1309 | struct PERF_TALER_EXCHANGEDB_Data *data; | ||
1310 | enum GNUNET_DB_QueryStatus qs; | ||
1311 | |||
1312 | reserve_index = | ||
1313 | state->cmd[state->i].details.get_reserve_history.index_reserve; | ||
1314 | data = &state->cmd[reserve_index].exposed; | ||
1315 | qs = state->plugin->get_reserve_history (state->plugin->cls, | ||
1316 | state->session, | ||
1317 | &data->data.reserve->reserve. | ||
1318 | pub, | ||
1319 | &history); | ||
1320 | GNUNET_assert (0 >= qs); | ||
1321 | GNUNET_assert (NULL != history); | ||
1322 | state->plugin->free_reserve_history (state->plugin->cls, | ||
1323 | history); | ||
1324 | } | ||
1325 | break; | ||
1326 | |||
1327 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION: | ||
1328 | { | ||
1329 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki = | ||
1330 | PERF_TALER_EXCHANGEDB_denomination_init (); | ||
1331 | GNUNET_assert (NULL != dki); | ||
1332 | state->cmd[state->i].exposed.data.dki = dki; | ||
1333 | } | ||
1334 | break; | ||
1335 | |||
1336 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: | ||
1337 | { | ||
1338 | unsigned int denom_index; | ||
1339 | enum GNUNET_DB_QueryStatus ret; | ||
1340 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; | ||
1341 | |||
1342 | denom_index = | ||
1343 | state->cmd[state->i].details.insert_denomination.index_denom; | ||
1344 | dki = state->cmd[denom_index].exposed.data.dki; | ||
1345 | ret = state->plugin->insert_denomination_info (state->plugin->cls, | ||
1346 | state->session, | ||
1347 | &dki->denom_pub, | ||
1348 | &dki->issue); | ||
1349 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == ret); | ||
1350 | } | ||
1351 | break; | ||
1352 | |||
1353 | case PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION: | ||
1354 | { | ||
1355 | unsigned int denom_index; | ||
1356 | enum GNUNET_DB_QueryStatus qs; | ||
1357 | struct PERF_TALER_EXCHANGEDB_Data *data; | ||
1358 | struct GNUNET_HashCode hc; | ||
1359 | |||
1360 | denom_index = state->cmd[state->i].details.get_denomination.index_denom; | ||
1361 | data = &state->cmd[denom_index].exposed; | ||
1362 | GNUNET_CRYPTO_rsa_public_key_hash ( | ||
1363 | data->data.dki->denom_pub.rsa_public_key, | ||
1364 | &hc); | ||
1365 | qs = state->plugin->get_denomination_info (state->plugin->cls, | ||
1366 | state->session, | ||
1367 | &hc, | ||
1368 | &data->data.dki->issue); | ||
1369 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1370 | } | ||
1371 | break; | ||
1372 | |||
1373 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW: | ||
1374 | { | ||
1375 | unsigned int dki_index; | ||
1376 | unsigned int reserve_index; | ||
1377 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
1378 | |||
1379 | dki_index = state->cmd[state->i].details.create_withdraw.index_dki; | ||
1380 | reserve_index = | ||
1381 | state->cmd[state->i].details.create_withdraw.index_reserve; | ||
1382 | coin = PERF_TALER_EXCHANGEDB_coin_init ( | ||
1383 | state->cmd[dki_index].exposed.data.dki, | ||
1384 | state->cmd[reserve_index]. | ||
1385 | exposed.data.reserve); | ||
1386 | GNUNET_assert (NULL != coin); | ||
1387 | state->cmd[state->i].exposed.data.coin = coin; | ||
1388 | } | ||
1389 | break; | ||
1390 | |||
1391 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW: | ||
1392 | { | ||
1393 | unsigned int coin_index; | ||
1394 | enum GNUNET_DB_QueryStatus qs; | ||
1395 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
1396 | |||
1397 | coin_index = state->cmd[state->i].details.insert_withdraw.index_coin; | ||
1398 | coin = state->cmd[coin_index].exposed.data.coin; | ||
1399 | qs = state->plugin->insert_withdraw_info (state->plugin->cls, | ||
1400 | state->session, | ||
1401 | &coin->blind); | ||
1402 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1403 | } | ||
1404 | break; | ||
1405 | |||
1406 | case PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW: | ||
1407 | { | ||
1408 | unsigned int source_index; | ||
1409 | enum GNUNET_DB_QueryStatus qs; | ||
1410 | struct PERF_TALER_EXCHANGEDB_Data *data; | ||
1411 | |||
1412 | source_index = | ||
1413 | state->cmd[state->i].details.get_denomination.index_denom; | ||
1414 | data = &state->cmd[source_index].exposed; | ||
1415 | qs = state->plugin->get_withdraw_info (state->plugin->cls, | ||
1416 | state->session, | ||
1417 | &data->data.coin->blind. | ||
1418 | h_coin_envelope, | ||
1419 | &data->data.coin->blind); | ||
1420 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1421 | } | ||
1422 | break; | ||
1423 | |||
1424 | case PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION: | ||
1425 | { | ||
1426 | unsigned int coin_index; | ||
1427 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
1428 | struct TALER_EXCHANGEDB_TransactionList *transactions; | ||
1429 | enum GNUNET_DB_QueryStatus qs; | ||
1430 | |||
1431 | coin_index = | ||
1432 | state->cmd[state->i].details.get_coin_transaction.index_coin; | ||
1433 | coin = state->cmd[coin_index].exposed.data.coin; | ||
1434 | qs = state->plugin->get_coin_transactions (state->plugin->cls, | ||
1435 | state->session, | ||
1436 | &coin->public_info.coin_pub, | ||
1437 | GNUNET_YES, | ||
1438 | &transactions); | ||
1439 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); | ||
1440 | GNUNET_assert (transactions != NULL); | ||
1441 | state->plugin->free_coin_transaction_list (state->plugin->cls, | ||
1442 | transactions); | ||
1443 | } | ||
1444 | break; | ||
1445 | |||
1446 | case PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION: | ||
1447 | { | ||
1448 | struct TALER_EXCHANGEDB_RefreshSession refresh_session; | ||
1449 | unsigned int coin_index; | ||
1450 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
1451 | |||
1452 | coin_index = | ||
1453 | state->cmd[state->i].details.create_refresh_session.index_coin; | ||
1454 | coin = state->cmd[coin_index].exposed.data.coin; | ||
1455 | |||
1456 | refresh_session.coin = coin->public_info; | ||
1457 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1458 | &refresh_session.coin_sig, | ||
1459 | sizeof (refresh_session.coin_sig)); | ||
1460 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1461 | &refresh_session.rc.session_hash); | ||
1462 | GNUNET_assert (GNUNET_OK == | ||
1463 | TALER_string_to_amount (CURRENCY ":1.1", | ||
1464 | &refresh_session.amount_with_fee)); | ||
1465 | refresh_session.noreveal_index = 1; | ||
1466 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == | ||
1467 | state->plugin->ensure_coin_known (state->plugin->cls, | ||
1468 | state->session, | ||
1469 | &refresh_session.coin)); | ||
1470 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == | ||
1471 | state->plugin->insert_melt (state->plugin->cls, | ||
1472 | state->session, | ||
1473 | &refresh_session)); | ||
1474 | state->cmd[state->i].exposed.data.rc = refresh_session.rc; | ||
1475 | } | ||
1476 | break; | ||
1477 | |||
1478 | case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION: | ||
1479 | { | ||
1480 | unsigned int hash_index; | ||
1481 | const struct TALER_RefreshCommitmentP *rc; | ||
1482 | struct TALER_EXCHANGEDB_RefreshMelt refresh; | ||
1483 | |||
1484 | hash_index = | ||
1485 | state->cmd[state->i].details.get_refresh_session.index_hash; | ||
1486 | rc = &state->cmd[hash_index].exposed.data.rc; | ||
1487 | state->plugin->get_melt (state->plugin->cls, | ||
1488 | state->session, | ||
1489 | rc, | ||
1490 | &refresh); | ||
1491 | } | ||
1492 | break; | ||
1493 | |||
1494 | case PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL: | ||
1495 | { | ||
1496 | unsigned int hash_index; | ||
1497 | unsigned int denom_index; | ||
1498 | const struct TALER_RefreshCommitmentP *rc; | ||
1499 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *denom; | ||
1500 | struct TALER_TransferPublicKeyP tpub; | ||
1501 | struct TALER_TransferPrivateKeyP tprivs[2]; | ||
1502 | struct TALER_EXCHANGEDB_RefreshRevealedCoin rrc; | ||
1503 | |||
1504 | hash_index = | ||
1505 | state->cmd[state->i].details.insert_refresh_reveal.index_hash; | ||
1506 | denom_index = | ||
1507 | state->cmd[state->i].details.insert_refresh_reveal.index_denom; | ||
1508 | rc = &state->cmd[hash_index].exposed.data.rc; | ||
1509 | denom = state->cmd[denom_index].exposed.data.dki; | ||
1510 | rrc.denom_pub = denom->denom_pub; | ||
1511 | rrc.coin_ev = "coin_ev"; | ||
1512 | rrc.coin_ev_size = strlen (rrc.coin_ev) + 1; | ||
1513 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1514 | &rrc.coin_sig, | ||
1515 | sizeof (struct TALER_CoinSpendSignatureP)); | ||
1516 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1517 | tprivs, | ||
1518 | sizeof (struct TALER_TransferPrivateKeyP) | ||
1519 | * 2); | ||
1520 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1521 | &tpub, | ||
1522 | sizeof (struct TALER_TransferPublicKeyP)); | ||
1523 | GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == | ||
1524 | state->plugin->insert_refresh_reveal (state->plugin->cls, | ||
1525 | state->session, | ||
1526 | rc, | ||
1527 | 1, | ||
1528 | &rrc, | ||
1529 | 2, | ||
1530 | tprivs, | ||
1531 | &tpub)); | ||
1532 | } | ||
1533 | break; | ||
1534 | |||
1535 | case PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL: | ||
1536 | { | ||
1537 | int hash_index; | ||
1538 | const struct TALER_RefreshCommitmentP *rc; | ||
1539 | |||
1540 | hash_index = state->cmd[state->i].details.get_refresh_reveal.index_hash; | ||
1541 | rc = &state->cmd[hash_index].exposed.data.rc; | ||
1542 | state->plugin->get_refresh_reveal (state->plugin->cls, | ||
1543 | state->session, | ||
1544 | rc, | ||
1545 | &refresh_reveal_cb, | ||
1546 | state); | ||
1547 | } | ||
1548 | break; | ||
1549 | |||
1550 | case PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA: | ||
1551 | break; | ||
1552 | |||
1553 | } | ||
1554 | } | ||
1555 | return GNUNET_OK; | ||
1556 | } | ||
1557 | |||
1558 | |||
1559 | /** | ||
1560 | * Runs the commands given in @a cmd, working with | ||
1561 | * the database referenced by @a db_plugin | ||
1562 | * | ||
1563 | * @param db_plugin the connection to the database | ||
1564 | * @param cmd the commands to run | ||
1565 | */ | ||
1566 | int | ||
1567 | PERF_TALER_EXCHANGEDB_interpret (struct TALER_EXCHANGEDB_Plugin *db_plugin, | ||
1568 | struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) | ||
1569 | { | ||
1570 | int ret; | ||
1571 | struct PERF_TALER_EXCHANGEDB_interpreter_state state = | ||
1572 | {.i = 0, .cmd = cmd, .plugin = db_plugin}; | ||
1573 | |||
1574 | ret = cmd_init (cmd); | ||
1575 | if (GNUNET_SYSERR == ret) | ||
1576 | return ret; | ||
1577 | state.session = db_plugin->get_session (db_plugin->cls); | ||
1578 | if (NULL == state.session) | ||
1579 | { | ||
1580 | cmd_clean (cmd); | ||
1581 | return GNUNET_SYSERR; | ||
1582 | } | ||
1583 | GNUNET_assert (NULL != state.session); | ||
1584 | ret = interpret (&state); | ||
1585 | cmd_clean (cmd); | ||
1586 | return ret; | ||
1587 | } | ||
1588 | |||
1589 | |||
1590 | /** | ||
1591 | * Initialize the database and run the benchmark | ||
1592 | * | ||
1593 | * @param benchmark_name the name of the benchmark, displayed in the logs | ||
1594 | * @param configuration_file path to the taler configuration file to use | ||
1595 | * @param init the commands to use for the database initialisation, | ||
1596 | * if #NULL the standard initialization is used | ||
1597 | * @param benchmark the commands for the benchmark | ||
1598 | * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure, #GNUNET_NO | ||
1599 | * if we failed to init the database | ||
1600 | */ | ||
1601 | int | ||
1602 | PERF_TALER_EXCHANGEDB_run_benchmark (const char *benchmark_name, | ||
1603 | const char *configuration_file, | ||
1604 | struct PERF_TALER_EXCHANGEDB_Cmd *init, | ||
1605 | struct PERF_TALER_EXCHANGEDB_Cmd *benchmark) | ||
1606 | { | ||
1607 | struct TALER_EXCHANGEDB_Plugin *plugin; | ||
1608 | struct GNUNET_CONFIGURATION_Handle *config; | ||
1609 | int ret = 0; | ||
1610 | struct PERF_TALER_EXCHANGEDB_Cmd init_def[] = { | ||
1611 | // Denomination used to create coins | ||
1612 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("00 - Start of interpreter"), | ||
1613 | |||
1614 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", | ||
1615 | PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT), | ||
1616 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
1617 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), | ||
1618 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", | ||
1619 | "01 - denomination"), | ||
1620 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
1621 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", | ||
1622 | "01 - denomination loop", | ||
1623 | "01 - denomination", | ||
1624 | PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE), | ||
1625 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
1626 | "01 - denomination loop"), | ||
1627 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("01 - init denomination complete"), | ||
1628 | // End of initialization | ||
1629 | // Reserve initialization | ||
1630 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", | ||
1631 | PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT), | ||
1632 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), | ||
1633 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", | ||
1634 | "02 - reserve"), | ||
1635 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", | ||
1636 | "02 - init reserve loop", | ||
1637 | "02 - reserve", | ||
1638 | PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE), | ||
1639 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
1640 | "02 - init reserve loop"), | ||
1641 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("02 - reserve init complete"), | ||
1642 | // End reserve init | ||
1643 | // Withdrawal initialization | ||
1644 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", | ||
1645 | PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT), | ||
1646 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), | ||
1647 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", | ||
1648 | "03 - init withdraw loop", | ||
1649 | "01 - save denomination"), | ||
1650 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", | ||
1651 | "03 - init withdraw loop", | ||
1652 | "02 - save reserve"), | ||
1653 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", | ||
1654 | "03 - denomination load", | ||
1655 | "03 - reserve load"), | ||
1656 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert", | ||
1657 | "03 - withdraw"), | ||
1658 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), | ||
1659 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin", | ||
1660 | "03 - init withdraw loop", | ||
1661 | "03 - withdraw", | ||
1662 | PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE), | ||
1663 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", | ||
1664 | "03 - init withdraw loop"), | ||
1665 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), | ||
1666 | // End of withdrawal initialization | ||
1667 | // Deposit initialization | ||
1668 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", | ||
1669 | PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT), | ||
1670 | PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"), | ||
1671 | PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - denomination load", | ||
1672 | "04 - deposit init loop", | ||
1673 | "03 - save coin"), | ||
1674 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", | ||
1675 | "04 - denomination load"), | ||
1676 | PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION ( | ||
1677 | "04 - commit transaction"), | ||
1678 | PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", | ||
1679 | "04 - deposit init loop", | ||
1680 | "04 - deposit", | ||
1681 | PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE), | ||
1682 | PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("04 - deposit init loop end", | ||
1683 | "04 - deposit init loop"), | ||
1684 | PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("04 - deposit init complete"), | ||
1685 | // End of deposit initialization | ||
1686 | PERF_TALER_EXCHANGEDB_INIT_CMD_END ("end") | ||
1687 | }; | ||
1688 | |||
1689 | GNUNET_log_setup (benchmark_name, | ||
1690 | "INFO", | ||
1691 | NULL); | ||
1692 | config = GNUNET_CONFIGURATION_create (); | ||
1693 | ret = GNUNET_CONFIGURATION_parse (config, | ||
1694 | configuration_file); | ||
1695 | if (GNUNET_OK != ret) | ||
1696 | { | ||
1697 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1698 | "Error parsing configuration file\n"); | ||
1699 | return GNUNET_SYSERR; | ||
1700 | } | ||
1701 | plugin = TALER_EXCHANGEDB_plugin_load (config); | ||
1702 | if (NULL == plugin) | ||
1703 | { | ||
1704 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1705 | "Error connectiong to the database\n"); | ||
1706 | return GNUNET_NO; | ||
1707 | } | ||
1708 | ret = plugin->create_tables (plugin->cls); | ||
1709 | if (GNUNET_OK != ret) | ||
1710 | { | ||
1711 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1712 | "Error while creating the database architecture\n"); | ||
1713 | return GNUNET_NO; | ||
1714 | } | ||
1715 | /* | ||
1716 | * Running the initialization | ||
1717 | */ | ||
1718 | if (NULL == init) | ||
1719 | { | ||
1720 | init = init_def; | ||
1721 | } | ||
1722 | ret = PERF_TALER_EXCHANGEDB_interpret (plugin, | ||
1723 | init); | ||
1724 | if (GNUNET_OK != ret) | ||
1725 | { | ||
1726 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1727 | "Error during database initialization\n"); | ||
1728 | return ret; | ||
1729 | } | ||
1730 | /* | ||
1731 | * Running the benchmark | ||
1732 | */ | ||
1733 | ret = PERF_TALER_EXCHANGEDB_interpret (plugin, | ||
1734 | benchmark); | ||
1735 | if (GNUNET_OK != ret) | ||
1736 | { | ||
1737 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1738 | "Error while runing the benchmark\n"); | ||
1739 | return ret; | ||
1740 | } | ||
1741 | /* Drop tables */ | ||
1742 | { | ||
1743 | ret = plugin->drop_tables (plugin->cls); | ||
1744 | if (GNUNET_OK != ret) | ||
1745 | { | ||
1746 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1747 | "Error cleaning the database\n"); | ||
1748 | return ret; | ||
1749 | } | ||
1750 | } | ||
1751 | TALER_EXCHANGEDB_plugin_unload (plugin); | ||
1752 | GNUNET_CONFIGURATION_destroy (config); | ||
1753 | return ret; | ||
1754 | } | ||
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.h b/src/exchangedb/perf_taler_exchangedb_interpreter.h deleted file mode 100644 index 414e33fe0..000000000 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.h +++ /dev/null | |||
@@ -1,1145 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014, 2015 GNUnet e.V. | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchangedb/perf_taler_exchangedb_interpreter.h | ||
18 | * @brief Library for performance analysis of the Taler database | ||
19 | * @author Nicolas Fournier | ||
20 | * | ||
21 | * This library contains functions and macro alowing Taler performance analysis | ||
22 | * to be written with ease. | ||
23 | * To do so, create a #PERF_TALER_EXCHANGEDB_Cmd array and fill it with the commands | ||
24 | * to execute in chronological order. Some command have an exposed variable wich | ||
25 | * can be reused in other commands. | ||
26 | * Macros are available to make the use much easier so feel free to use them | ||
27 | * to initialize your own command array. | ||
28 | */ | ||
29 | |||
30 | #ifndef __PERF_TALER_EXCHANGEDB_INTERPRETER_H__ | ||
31 | #define __PERF_TALER_EXCHANGEDB_INTERPRETER_H__ | ||
32 | |||
33 | #include <sys/time.h> | ||
34 | #include "taler_exchangedb_plugin.h" | ||
35 | |||
36 | |||
37 | #define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_INIT 10 | ||
38 | #define PERF_TALER_EXCHANGEDB_NB_DENOMINATION_SAVE 10 | ||
39 | |||
40 | #define PERF_TALER_EXCHANGEDB_NB_RESERVE_INIT 100 | ||
41 | #define PERF_TALER_EXCHANGEDB_NB_RESERVE_SAVE 10 | ||
42 | |||
43 | #define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_INIT 100 | ||
44 | #define PERF_TALER_EXCHANGEDB_NB_DEPOSIT_SAVE 10 | ||
45 | |||
46 | #define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_INIT 100 | ||
47 | #define PERF_TALER_EXCHANGEDB_NB_WITHDRAW_SAVE 10 | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Marks the end of the command chain | ||
52 | * | ||
53 | * @param _label The label of the command | ||
54 | */ | ||
55 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_END(_label) \ | ||
56 | { \ | ||
57 | .command = PERF_TALER_EXCHANGEDB_CMD_END, \ | ||
58 | .label = _label, \ | ||
59 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ | ||
60 | } | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Prints @ _label to stdout | ||
65 | * | ||
66 | * @param _label The label of the command, | ||
67 | * will be logged each time the command runs | ||
68 | */ | ||
69 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG(_label) \ | ||
70 | { \ | ||
71 | .command = PERF_TALER_EXCHANGEDB_CMD_DEBUG, \ | ||
72 | .label = _label, \ | ||
73 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * The begining of a loop | ||
78 | * | ||
79 | * @param _label the label of the loop | ||
80 | * @param _iter the number of iterations of the loop | ||
81 | */ | ||
82 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP(_label, _iter) \ | ||
83 | { \ | ||
84 | .command = PERF_TALER_EXCHANGEDB_CMD_LOOP, \ | ||
85 | .label = _label, \ | ||
86 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
87 | .details.loop = { \ | ||
88 | .max_iterations = _iter, \ | ||
89 | .curr_iteration = 0 } \ | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * Marks the end of the loop @_label_loop | ||
94 | * | ||
95 | * @param _label the label of the command | ||
96 | * @param _label_loop the label of the loop closed by this command | ||
97 | */ | ||
98 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP(_label, _label_loop) \ | ||
99 | { \ | ||
100 | .command = PERF_TALER_EXCHANGEDB_CMD_END_LOOP, \ | ||
101 | .label = _label, \ | ||
102 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
103 | .details.end_loop.label_loop = _label_loop \ | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * Saves the time of execution to use for logging with Gauger | ||
108 | * | ||
109 | * @param _label the label of the command | ||
110 | */ | ||
111 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME(_label) \ | ||
112 | { \ | ||
113 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_TIME, \ | ||
114 | .label = _label, \ | ||
115 | .exposed.type = PERF_TALER_EXCHANGEDB_TIME \ | ||
116 | } | ||
117 | |||
118 | /** | ||
119 | * Commits the duration between @a _label_start and @a _label_stop | ||
120 | * to Gauger with @a _description explaining what was measured. | ||
121 | * | ||
122 | * @param _label the label of this command | ||
123 | * @param _label_start label of the start of the measurment | ||
124 | * @param _label_stop label of the end of the measurment | ||
125 | * @param _description description of the measure displayed in Gauger | ||
126 | * @param _unit the unit of the data measured, typicly something/sec | ||
127 | * @param _divide number of measurments in the interval | ||
128 | */ | ||
129 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, \ | ||
130 | _category, _description, _unit, \ | ||
131 | _divide) \ | ||
132 | { \ | ||
133 | .command = PERF_TALER_EXCHANGEDB_CMD_GAUGER, \ | ||
134 | .label = _label, \ | ||
135 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
136 | .details.gauger = { \ | ||
137 | .label_start = _label_start, \ | ||
138 | .label_stop = _label_stop, \ | ||
139 | .category = _category, \ | ||
140 | .description = _description, \ | ||
141 | .unit = _unit, \ | ||
142 | .divide = _divide, \ | ||
143 | } \ | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * Initiate a database transaction | ||
148 | * | ||
149 | * @param _label the label of the command | ||
150 | */ | ||
151 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION(_label) \ | ||
152 | { \ | ||
153 | .command = PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, \ | ||
154 | .label = _label, \ | ||
155 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Commits a database transaction | ||
160 | * | ||
161 | * @param _label the label of the command | ||
162 | */ | ||
163 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION(_label) \ | ||
164 | { \ | ||
165 | .command = PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, \ | ||
166 | .label = _label, \ | ||
167 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Abort the current transaction | ||
172 | * | ||
173 | * @param _label the label of the command | ||
174 | */ | ||
175 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_ABORT_TRANSACTION(_label) \ | ||
176 | { \ | ||
177 | .command = PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, \ | ||
178 | .label = _label, | ||
179 | |||
180 | /** | ||
181 | * Saves randomly selected items from @a _label_save | ||
182 | * Saved items can latter be access using #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY | ||
183 | * | ||
184 | * @param _label the label of the command, used by other commands to reference it | ||
185 | * @param _label_loop the label of the loop the array iterates over | ||
186 | * @param _label_save the label of the command which outout is saved by this command | ||
187 | * @param _nb_saved the total number of items to be saved | ||
188 | */ | ||
189 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, \ | ||
190 | _label_save, _nb_saved) \ | ||
191 | { \ | ||
192 | .command = PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, \ | ||
193 | .label = _label, \ | ||
194 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
195 | .details.save_array = { \ | ||
196 | .label_loop = _label_loop, \ | ||
197 | .label_save = _label_save, \ | ||
198 | .nb_saved = _nb_saved, \ | ||
199 | } \ | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Loads data from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY to allow other | ||
204 | * commands to access it | ||
205 | * | ||
206 | * @param _label the label of this command, referenced by commands to access it's outpout | ||
207 | * @param _label_loop the label of the loop to iterate over | ||
208 | * @param _label_save the label of the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY providing data | ||
209 | */ | ||
210 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, \ | ||
211 | _label_save) \ | ||
212 | { \ | ||
213 | .command = PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, \ | ||
214 | .label = _label, \ | ||
215 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
216 | .details.load_array = { \ | ||
217 | .label_loop = _label_loop, \ | ||
218 | .label_save = _label_save \ | ||
219 | } \ | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * Create a denomination key to use | ||
224 | * Exposes a #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO to be used by other commands | ||
225 | * @exposed #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO | ||
226 | * | ||
227 | * @param _label the label of this command | ||
228 | */ | ||
229 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION(_label) \ | ||
230 | { \ | ||
231 | .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, \ | ||
232 | .label = _label, \ | ||
233 | .exposed.type = PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, \ | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Inserts informations about a denomination key in the database | ||
238 | * | ||
239 | * @param _label the label of this command | ||
240 | * @param _label_denom the label of the denomination to insert | ||
241 | */ | ||
242 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION(_label, _label_denom) \ | ||
243 | { \ | ||
244 | .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, \ | ||
245 | .label = _label, \ | ||
246 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
247 | .details.insert_denomination.label_denom = _label_denom, \ | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * Polls the database about informations regarding a specific denomination key | ||
252 | * | ||
253 | * @param _label the label of this command | ||
254 | * @param _label_denom the label of the command providing information about the denomination key | ||
255 | */ | ||
256 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION(_label, _label_denom) \ | ||
257 | { \ | ||
258 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, \ | ||
259 | .label = _label, \ | ||
260 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
261 | .details.get_denomination.label_denom = _label_denom \ | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * Create a reserve to be used later | ||
266 | * Exposes a #PERF_TALER_EXCHANGEDB_RESERVE | ||
267 | * | ||
268 | * @param _label the label of the command | ||
269 | */ | ||
270 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE(_label) \ | ||
271 | { \ | ||
272 | .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, \ | ||
273 | .label = _label, \ | ||
274 | .exposed.type = PERF_TALER_EXCHANGEDB_RESERVE \ | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * Insert a new reserve in the database containing 1000 Euros | ||
279 | * | ||
280 | * @param _label the name of this command | ||
281 | * @param _label_reserve the label of the reserve to insert | ||
282 | */ | ||
283 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE(_label, _label_reserve) \ | ||
284 | { \ | ||
285 | .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, \ | ||
286 | .label = _label, \ | ||
287 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
288 | .details.insert_reserve.label_reserve = _label_reserve \ | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * Polls the database for a secific reserve's details | ||
293 | * | ||
294 | * @param _label the label of this command | ||
295 | * @param _label_reserve the reserve to poll | ||
296 | */ | ||
297 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE(_label, _label_reserve) \ | ||
298 | { \ | ||
299 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, \ | ||
300 | .label = _label, \ | ||
301 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
302 | .details.get_reserve.label_reserve = _label_reserve \ | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * Polls the database for the history of a reserve | ||
307 | * | ||
308 | * @param _label the label of the command | ||
309 | * @param _label_reserve the reserve to examine | ||
310 | */ | ||
311 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY(_label, \ | ||
312 | _label_reserve) \ | ||
313 | { \ | ||
314 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, \ | ||
315 | .label = _label, \ | ||
316 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
317 | .details.get_reserve_history.label_reserve = _label_reserve \ | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Creates a coin to be used later | ||
322 | * | ||
323 | * @param _label the label of this command | ||
324 | * @param _label_dki denomination key used to sign the coin | ||
325 | * @param _label_reserve reserve used to emmit the coin | ||
326 | */ | ||
327 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW(_label, _label_dki, \ | ||
328 | _label_reserve) \ | ||
329 | { \ | ||
330 | .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, \ | ||
331 | .label = _label, \ | ||
332 | .exposed.type = PERF_TALER_EXCHANGEDB_COIN, \ | ||
333 | .details.create_withdraw = { \ | ||
334 | .label_dki = _label_dki, \ | ||
335 | .label_reserve = _label_reserve, \ | ||
336 | } \ | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Inserts information about a withdrawal into the database | ||
341 | * | ||
342 | * @exposes #PERF_TALER_EXCHANGEDB_COIN | ||
343 | * | ||
344 | * @param _label the label of this command | ||
345 | * @param _label_coin the coin to insert | ||
346 | */ | ||
347 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW(_label, _label_coin) \ | ||
348 | { \ | ||
349 | .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, \ | ||
350 | .label = _label, \ | ||
351 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
352 | .details.insert_withdraw.label_coin = _label_coin \ | ||
353 | } | ||
354 | |||
355 | |||
356 | /** | ||
357 | * Polls the database about informations regarding a specific withdrawal | ||
358 | * | ||
359 | * @param _label the label of this command | ||
360 | * @param _label_coin the coin to check | ||
361 | */ | ||
362 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW(_label, _label_coin) \ | ||
363 | { \ | ||
364 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, \ | ||
365 | .label = _label, \ | ||
366 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
367 | .details.get_withdraw.label_coin = _label_coin, \ | ||
368 | } | ||
369 | |||
370 | |||
371 | /** | ||
372 | * The /reserve/withdraw api call | ||
373 | * | ||
374 | * Exposes #PERF_TALER_EXCHANGEDB_COIN | ||
375 | * | ||
376 | * @param _label the label of this command | ||
377 | * @param _label_dki the denomination of the created coin | ||
378 | * @param _label_reserve the reserve used to provide currency | ||
379 | */ | ||
380 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, \ | ||
381 | _label_reserve) \ | ||
382 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW (_label "withdraw", \ | ||
383 | _label_dki, \ | ||
384 | _label_reserve), \ | ||
385 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DENOMINATION (_label "withdraw info", \ | ||
386 | _label_dki), \ | ||
387 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY (_label "reserve_history", \ | ||
388 | _label_reserve), \ | ||
389 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW (_label "insert withdraw", \ | ||
390 | _label "withdraw") | ||
391 | |||
392 | /** | ||
393 | * Create a deposit for use later | ||
394 | * @exposes #PERF_TALER_EXCHANGEDB_DEPOSIT | ||
395 | * | ||
396 | * @param _label the label of this command | ||
397 | * @param _label_coin the coin used to pay | ||
398 | */ | ||
399 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT(_label, _label_coin) \ | ||
400 | { \ | ||
401 | .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, \ | ||
402 | .label = _label, \ | ||
403 | .exposed.type = PERF_TALER_EXCHANGEDB_DEPOSIT, \ | ||
404 | .details.create_deposit.label_coin = _label_coin, \ | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Insert a deposit into the database | ||
409 | * | ||
410 | * @param _label the label of this command | ||
411 | * @param _label_deposit the deposit inseerted | ||
412 | */ | ||
413 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_deposit) \ | ||
414 | { \ | ||
415 | .command = PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT, \ | ||
416 | .label = _label, \ | ||
417 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
418 | .details.insert_deposit.label_deposit = _label_deposit, \ | ||
419 | } | ||
420 | |||
421 | /** | ||
422 | * Check if a deposit is in the database | ||
423 | * | ||
424 | * @param _label the label of this command | ||
425 | * @param _label_deposit the deposit to use | ||
426 | */ | ||
427 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \ | ||
428 | { \ | ||
429 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, \ | ||
430 | .label = _label, \ | ||
431 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
432 | .details.get_deposit.label_deposit = _label_deposit \ | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * Access the transaction history of a coin | ||
437 | * | ||
438 | * @param _label the label of the command | ||
439 | * @param _label_coin the coin which history is checked | ||
440 | */ | ||
441 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION(_label, _label_coin) \ | ||
442 | { \ | ||
443 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, \ | ||
444 | .label = _label, \ | ||
445 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE, \ | ||
446 | .details.get_coin_transaction.label_coin = _label_coin \ | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * The /deposit api call | ||
451 | * | ||
452 | * @param _label the label of the command | ||
453 | * @param _label_coin the coin used for the deposit | ||
454 | */ | ||
455 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT(_label, _label_coin) \ | ||
456 | PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION (_label "coin history", \ | ||
457 | _label_coin), \ | ||
458 | PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT (_label "deposit", \ | ||
459 | _label_coin), \ | ||
460 | PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT (_label "insert", \ | ||
461 | _label "deposit") | ||
462 | |||
463 | /** | ||
464 | * Insert informations about a refresh session | ||
465 | * melts one coin into another | ||
466 | * | ||
467 | * @param _label the label of the command | ||
468 | */ | ||
469 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION(_label, \ | ||
470 | _label_coin) \ | ||
471 | { \ | ||
472 | .command = PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, \ | ||
473 | .label = _label, \ | ||
474 | .details.create_refresh_session.label_coin = _label_coin, \ | ||
475 | .exposed.type = PERF_TALER_EXCHANGEDB_REFRESH_HASH \ | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Get informations about a refresh session | ||
480 | * | ||
481 | * @param _label the label of the command | ||
482 | * @param _label_hash the label of the hash to search | ||
483 | */ | ||
484 | #define PERF_TALER_EXCHANGEDB_INIT_CMD_GET_REFRESH_SESSION(_label, \ | ||
485 | _label_hash) \ | ||
486 | { \ | ||
487 | .command = PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, \ | ||
488 | .label = _label, \ | ||
489 | .exposed.type = PERF_TALER_EXCHANGEDB_NONE \ | ||
490 | } | ||
491 | |||
492 | |||
493 | /** | ||
494 | * The type of data stored in #PERF_TALER_EXCHANGEDB_Memory | ||
495 | */ | ||
496 | enum PERF_TALER_EXCHANGEDB_Type | ||
497 | { | ||
498 | PERF_TALER_EXCHANGEDB_NONE, | ||
499 | PERF_TALER_EXCHANGEDB_TIME, | ||
500 | PERF_TALER_EXCHANGEDB_DENOMINATION_INFO, | ||
501 | PERF_TALER_EXCHANGEDB_RESERVE, | ||
502 | PERF_TALER_EXCHANGEDB_COIN, | ||
503 | PERF_TALER_EXCHANGEDB_DEPOSIT, | ||
504 | PERF_TALER_EXCHANGEDB_REFRESH_HASH | ||
505 | }; | ||
506 | |||
507 | |||
508 | /** | ||
509 | * Structure used to handle several data type | ||
510 | */ | ||
511 | struct PERF_TALER_EXCHANGEDB_Data | ||
512 | { | ||
513 | enum PERF_TALER_EXCHANGEDB_Type type; | ||
514 | |||
515 | /** | ||
516 | * Storage for a variety of data type | ||
517 | * The data saved should match #type | ||
518 | */ | ||
519 | union PERF_TALER_EXCHANGEDB_Memory | ||
520 | { | ||
521 | /** #PERF_TALER_EXCHANGEDB_TIME */ | ||
522 | struct GNUNET_TIME_Absolute *time; | ||
523 | /** #PERF_TALER_EXCHANGEDB_DEPOSIT */ | ||
524 | struct TALER_EXCHANGEDB_Deposit *deposit; | ||
525 | /** #PERF_TALER_EXCHANGEDB_COIN */ | ||
526 | struct PERF_TALER_EXCHANGEDB_Coin *coin; | ||
527 | /** #PERF_TALER_EXCHANGEDB_RESERVE */ | ||
528 | struct PERF_TALER_EXCHANGEDB_Reserve *reserve; | ||
529 | /** #PERF_TALER_EXCHANGEDB_DENOMINATION_INFO */ | ||
530 | struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; | ||
531 | /** #PERF_TALER_EXCHANGEDB_REFRESH_HASH */ | ||
532 | struct TALER_RefreshCommitmentP rc; | ||
533 | } data; | ||
534 | }; | ||
535 | |||
536 | |||
537 | /** | ||
538 | * Name of the command | ||
539 | */ | ||
540 | enum PERF_TALER_EXCHANGEDB_CMD_Name | ||
541 | { | ||
542 | /** | ||
543 | * All comand chain must hace this as their last command | ||
544 | */ | ||
545 | PERF_TALER_EXCHANGEDB_CMD_END, | ||
546 | |||
547 | /** | ||
548 | * Prints it's label | ||
549 | */ | ||
550 | PERF_TALER_EXCHANGEDB_CMD_DEBUG, | ||
551 | |||
552 | /** | ||
553 | * Define the start of al command chain loop | ||
554 | */ | ||
555 | PERF_TALER_EXCHANGEDB_CMD_LOOP, | ||
556 | |||
557 | /** | ||
558 | * Define the end of a command chain loop | ||
559 | */ | ||
560 | PERF_TALER_EXCHANGEDB_CMD_END_LOOP, | ||
561 | |||
562 | /** | ||
563 | * Save the time at which the command was executed | ||
564 | */ | ||
565 | PERF_TALER_EXCHANGEDB_CMD_GET_TIME, | ||
566 | |||
567 | /** | ||
568 | * Upload performance to Gauger | ||
569 | */ | ||
570 | PERF_TALER_EXCHANGEDB_CMD_GAUGER, | ||
571 | |||
572 | /** | ||
573 | * Start a new session | ||
574 | */ | ||
575 | PERF_TALER_EXCHANGEDB_CMD_NEW_SESSION, | ||
576 | |||
577 | /** | ||
578 | * Start a database transaction | ||
579 | */ | ||
580 | PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION, | ||
581 | |||
582 | /** | ||
583 | * End a database transaction | ||
584 | */ | ||
585 | PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION, | ||
586 | |||
587 | /** | ||
588 | * Abort a transaction started with #PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION | ||
589 | */ | ||
590 | PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION, | ||
591 | |||
592 | /** | ||
593 | * Saves random deposits from a loop | ||
594 | */ | ||
595 | PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY, | ||
596 | |||
597 | /** | ||
598 | * Load items saved earlier in a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY | ||
599 | * The items are loaded in a random order, but all of them will be loaded | ||
600 | */ | ||
601 | PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY, | ||
602 | |||
603 | /** | ||
604 | * Loads a random item from a #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY | ||
605 | * A random item is loaded each time the command is run | ||
606 | */ | ||
607 | PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM, | ||
608 | |||
609 | /** | ||
610 | * Create a denomination to be used later | ||
611 | */ | ||
612 | PERF_TALER_EXCHANGEDB_CMD_CREATE_DENOMINATION, | ||
613 | |||
614 | /** | ||
615 | * Insert informations about a denomination key in the database | ||
616 | */ | ||
617 | PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION, | ||
618 | |||
619 | /** | ||
620 | * Polls the database for informations about a specific denomination key | ||
621 | */ | ||
622 | PERF_TALER_EXCHANGEDB_CMD_GET_DENOMINATION, | ||
623 | |||
624 | /** | ||
625 | * Create a reserve to be used later | ||
626 | */ | ||
627 | PERF_TALER_EXCHANGEDB_CMD_CREATE_RESERVE, | ||
628 | |||
629 | /** | ||
630 | * Insert currency in a reserve / Create a reserve | ||
631 | */ | ||
632 | PERF_TALER_EXCHANGEDB_CMD_INSERT_RESERVE, | ||
633 | |||
634 | /** | ||
635 | * Get Informations about a reserve | ||
636 | */ | ||
637 | PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE, | ||
638 | |||
639 | /** | ||
640 | * Get the history of a reserve | ||
641 | */ | ||
642 | PERF_TALER_EXCHANGEDB_CMD_GET_RESERVE_HISTORY, | ||
643 | |||
644 | /** | ||
645 | * Create a withdrawal to be used later | ||
646 | */ | ||
647 | PERF_TALER_EXCHANGEDB_CMD_CREATE_WITHDRAW, | ||
648 | |||
649 | /** | ||
650 | * Insert informations about a withdrawal in the database | ||
651 | */ | ||
652 | PERF_TALER_EXCHANGEDB_CMD_INSERT_WITHDRAW, | ||
653 | |||
654 | /** | ||
655 | * Pulls informations about a withdrawal from the database | ||
656 | */ | ||
657 | PERF_TALER_EXCHANGEDB_CMD_GET_WITHDRAW, | ||
658 | |||
659 | /** | ||
660 | * Get the list of all transactions the coin has been in | ||
661 | */ | ||
662 | PERF_TALER_EXCHANGEDB_CMD_GET_COIN_TRANSACTION, | ||
663 | |||
664 | /** | ||
665 | * Create a deposit to be used later | ||
666 | */ | ||
667 | PERF_TALER_EXCHANGEDB_CMD_CREATE_DEPOSIT, | ||
668 | |||
669 | /** | ||
670 | * Insert a deposit into the database | ||
671 | */ | ||
672 | PERF_TALER_EXCHANGEDB_CMD_INSERT_DEPOSIT, | ||
673 | |||
674 | /** | ||
675 | * Check if a deposit is in the database | ||
676 | */ | ||
677 | PERF_TALER_EXCHANGEDB_CMD_GET_DEPOSIT, | ||
678 | |||
679 | /** | ||
680 | * Create a refresh session | ||
681 | * The number of melted coins is 1, | ||
682 | * The number of exchangeed coins is 1 | ||
683 | */ | ||
684 | PERF_TALER_EXCHANGEDB_CMD_CREATE_REFRESH_SESSION, | ||
685 | |||
686 | /** | ||
687 | * Get a refresh session informations | ||
688 | */ | ||
689 | PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_SESSION, | ||
690 | |||
691 | /** | ||
692 | * Insert a melt refresh reveal data | ||
693 | */ | ||
694 | PERF_TALER_EXCHANGEDB_CMD_INSERT_REFRESH_REVEAL, | ||
695 | |||
696 | /** | ||
697 | * Get informations about a refresh reveal data | ||
698 | */ | ||
699 | PERF_TALER_EXCHANGEDB_CMD_GET_REFRESH_REVEAL, | ||
700 | |||
701 | /** | ||
702 | * Get the link data list of a coin | ||
703 | */ | ||
704 | PERF_TALER_EXCHANGEDB_CMD_GET_LINK_DATA | ||
705 | |||
706 | }; | ||
707 | |||
708 | |||
709 | /** | ||
710 | * Contains extra data required for any command | ||
711 | */ | ||
712 | union PERF_TALER_EXCHANGEDB_CMD_Details | ||
713 | { | ||
714 | /** | ||
715 | * Extra data requiered for the #PERF_TALER_EXCHANGEDB_CMD_LOOP command | ||
716 | */ | ||
717 | struct PERF_TALER_EXCHANGEDB_CMD_loopDetails | ||
718 | { | ||
719 | /** | ||
720 | * Maximum number of iteration in the loop | ||
721 | */ | ||
722 | const unsigned int max_iterations; | ||
723 | |||
724 | /** | ||
725 | * The current iteration of the loop | ||
726 | */ | ||
727 | unsigned int curr_iteration; | ||
728 | } loop; | ||
729 | |||
730 | /** | ||
731 | * Extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_END_LOOP command | ||
732 | */ | ||
733 | struct PERF_TALER_EXCHANGEDB_CMD_endLoopDetails | ||
734 | { | ||
735 | /** | ||
736 | * Label of the loop closed by the command | ||
737 | */ | ||
738 | const char *label_loop; | ||
739 | unsigned int index_loop; | ||
740 | } end_loop; | ||
741 | |||
742 | /** | ||
743 | * Details about the #PERF_TALER_EXCHANGEDB_CMD_GAUGER command | ||
744 | */ | ||
745 | struct PERF_TALER_EXCHANGEDB_CMD_gaugerDetails | ||
746 | { | ||
747 | /** | ||
748 | * Label of the starting timestamp | ||
749 | */ | ||
750 | const char *label_start; | ||
751 | unsigned int index_start; | ||
752 | |||
753 | /** | ||
754 | * Label of the ending timestamp | ||
755 | */ | ||
756 | const char *label_stop; | ||
757 | unsigned int index_stop; | ||
758 | |||
759 | /** | ||
760 | * The category of the measurment | ||
761 | */ | ||
762 | const char *category; | ||
763 | |||
764 | /** | ||
765 | * Description of the metric, used in Gauger | ||
766 | */ | ||
767 | const char *description; | ||
768 | |||
769 | /** | ||
770 | * The name of the metric beeing used | ||
771 | */ | ||
772 | const char *unit; | ||
773 | |||
774 | /** | ||
775 | * Constant the result needs to be divided by | ||
776 | * to get the result per unit | ||
777 | */ | ||
778 | float divide; | ||
779 | } gauger; | ||
780 | |||
781 | /** | ||
782 | * Contains extra data requiered by the #PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY command | ||
783 | */ | ||
784 | struct PERF_TALER_EXCHANGEDB_CMD_saveArrayDetails | ||
785 | { | ||
786 | /** | ||
787 | * Number of items to save | ||
788 | */ | ||
789 | unsigned int nb_saved; | ||
790 | |||
791 | /** | ||
792 | * Number of items already saved | ||
793 | */ | ||
794 | unsigned int index; | ||
795 | |||
796 | /** | ||
797 | * Label of the loop it is attached to | ||
798 | */ | ||
799 | const char *label_loop; | ||
800 | unsigned int index_loop; | ||
801 | |||
802 | /** | ||
803 | * Label of the command exposing the item | ||
804 | */ | ||
805 | const char *label_save; | ||
806 | unsigned int index_save; | ||
807 | |||
808 | /** | ||
809 | * Array of data saved | ||
810 | */ | ||
811 | struct PERF_TALER_EXCHANGEDB_Data *data_saved; | ||
812 | |||
813 | /** | ||
814 | * Type of the data that will be stored in @a data_saved, for | ||
815 | * 'static' type checking. | ||
816 | */ | ||
817 | enum PERF_TALER_EXCHANGEDB_Type type_saved; | ||
818 | |||
819 | } save_array; | ||
820 | |||
821 | /** | ||
822 | * Extra data required for the #PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY command | ||
823 | */ | ||
824 | struct PERF_TALER_EXCHANGEDB_CMD_loadArrayDetails | ||
825 | { | ||
826 | /** | ||
827 | * The loop in which the command is located | ||
828 | */ | ||
829 | const char *label_loop; | ||
830 | unsigned int index_loop; | ||
831 | |||
832 | /** | ||
833 | * Label of the command where the items were saved | ||
834 | */ | ||
835 | const char *label_save; | ||
836 | unsigned int index_save; | ||
837 | |||
838 | /** | ||
839 | * A permutation array used to randomize the order the items are loaded in | ||
840 | */ | ||
841 | unsigned int *permutation; | ||
842 | } load_array; | ||
843 | |||
844 | /** | ||
845 | * Contains data for the #PERF_ |