aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-12 13:13:42 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-12 13:13:42 +0200
commitf174781b570bb534db424e57a3b563a74ad36f77 (patch)
tree6f9b533837e57b3cfe8009318ab99c6352164655
parent10d8342f90573215867adc9c7e561f09a61a7566 (diff)
downloadexchange-f174781b570bb534db424e57a3b563a74ad36f77.tar.gz
exchange-f174781b570bb534db424e57a3b563a74ad36f77.zip
support long_poll_ms argument in bank API (#6987)
-rw-r--r--src/auditor/taler-helper-auditor-wire.c22
-rw-r--r--src/bank-lib/Makefile.am1
-rw-r--r--src/bank-lib/bank_api_credit.c56
-rw-r--r--src/bank-lib/bank_api_debit.c81
-rw-r--r--src/bank-lib/fakebank.c12
-rw-r--r--src/bank-lib/taler-exchange-wire-gateway-client.c18
-rw-r--r--src/bank-lib/taler-fakebank-run.c13
-rw-r--r--src/benchmark/taler-bank-benchmark.c3
-rw-r--r--src/exchange/taler-exchange-wirewatch.c11
-rw-r--r--src/include/taler_bank_service.h16
-rw-r--r--src/include/taler_fakebank_lib.h4
-rw-r--r--src/testing/testing_api_cmd_bank_history_credit.c40
-rw-r--r--src/testing/testing_api_cmd_bank_history_debit.c11
13 files changed, 167 insertions, 121 deletions
diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c
index 8dded816f..eee186ca3 100644
--- a/src/auditor/taler-helper-auditor-wire.c
+++ b/src/auditor/taler-helper-auditor-wire.c
@@ -1014,7 +1014,7 @@ wire_out_cb (void *cls,
1014 1014
1015 payto_uri = TALER_JSON_wire_to_payto (wire); 1015 payto_uri = TALER_JSON_wire_to_payto (wire);
1016 if (0 != strcasecmp (payto_uri, 1016 if (0 != strcasecmp (payto_uri,
1017 roi->details.credit_account_url)) 1017 roi->details.credit_account_uri))
1018 { 1018 {
1019 /* Destination bank account is wrong in actual wire transfer, so 1019 /* Destination bank account is wrong in actual wire transfer, so
1020 we should count the wire transfer as entirely spurious, and 1020 we should count the wire transfer as entirely spurious, and
@@ -1055,7 +1055,7 @@ wire_out_cb (void *cls,
1055 "receiver account mismatch"), 1055 "receiver account mismatch"),
1056 GNUNET_JSON_pack_string ("target", 1056 GNUNET_JSON_pack_string ("target",
1057 roi->details. 1057 roi->details.
1058 credit_account_url), 1058 credit_account_uri),
1059 GNUNET_JSON_pack_string ("account_section", 1059 GNUNET_JSON_pack_string ("account_section",
1060 wa->ai->section_name))); 1060 wa->ai->section_name)));
1061 TALER_ARL_amount_add (&total_bad_amount_out_minus, 1061 TALER_ARL_amount_add (&total_bad_amount_out_minus,
@@ -1165,7 +1165,7 @@ check_rc_matches (void *cls,
1165 if ( (0 == GNUNET_memcmp (&ctx->roi->details.wtid, 1165 if ( (0 == GNUNET_memcmp (&ctx->roi->details.wtid,
1166 &rc->wtid)) && 1166 &rc->wtid)) &&
1167 (0 == strcasecmp (rc->receiver_account, 1167 (0 == strcasecmp (rc->receiver_account,
1168 ctx->roi->details.credit_account_url)) && 1168 ctx->roi->details.credit_account_uri)) &&
1169 (0 == TALER_amount_cmp (&rc->amount, 1169 (0 == TALER_amount_cmp (&rc->amount,
1170 &ctx->roi->details.amount)) ) 1170 &ctx->roi->details.amount)) )
1171 { 1171 {
@@ -1207,7 +1207,7 @@ complain_out_not_found (void *cls,
1207 }; 1207 };
1208 1208
1209 (void) key; 1209 (void) key;
1210 hash_rc (roi->details.credit_account_url, 1210 hash_rc (roi->details.credit_account_uri,
1211 &roi->details.wtid, 1211 &roi->details.wtid,
1212 &rkey); 1212 &rkey);
1213 GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures, 1213 GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures,
@@ -1341,7 +1341,7 @@ history_debit_cb (void *cls,
1341 TALER_B2S (&details->wtid)); 1341 TALER_B2S (&details->wtid));
1342 /* Update offset */ 1342 /* Update offset */
1343 wa->out_wire_off = row_off; 1343 wa->out_wire_off = row_off;
1344 slen = strlen (details->credit_account_url) + 1; 1344 slen = strlen (details->credit_account_uri) + 1;
1345 roi = GNUNET_malloc (sizeof (struct ReserveOutInfo) 1345 roi = GNUNET_malloc (sizeof (struct ReserveOutInfo)
1346 + slen); 1346 + slen);
1347 GNUNET_CRYPTO_hash (&details->wtid, 1347 GNUNET_CRYPTO_hash (&details->wtid,
@@ -1350,9 +1350,9 @@ history_debit_cb (void *cls,
1350 roi->details.amount = details->amount; 1350 roi->details.amount = details->amount;
1351 roi->details.execution_date = details->execution_date; 1351 roi->details.execution_date = details->execution_date;
1352 roi->details.wtid = details->wtid; 1352 roi->details.wtid = details->wtid;
1353 roi->details.credit_account_url = (const char *) &roi[1]; 1353 roi->details.credit_account_uri = (const char *) &roi[1];
1354 memcpy (&roi[1], 1354 memcpy (&roi[1],
1355 details->credit_account_url, 1355 details->credit_account_uri,
1356 slen); 1356 slen);
1357 if (GNUNET_OK != 1357 if (GNUNET_OK !=
1358 GNUNET_CONTAINER_multihashmap_put (out_map, 1358 GNUNET_CONTAINER_multihashmap_put (out_map,
@@ -1414,6 +1414,7 @@ process_debits (void *cls)
1414 wa->ai->auth, 1414 wa->ai->auth,
1415 wa->out_wire_off, 1415 wa->out_wire_off,
1416 INT64_MAX, 1416 INT64_MAX,
1417 GNUNET_TIME_UNIT_ZERO,
1417 &history_debit_cb, 1418 &history_debit_cb,
1418 wa); 1419 wa);
1419 if (NULL == wa->dhh) 1420 if (NULL == wa->dhh)
@@ -1496,7 +1497,7 @@ reserve_in_cb (void *cls,
1496 rii->details.amount = *credit; 1497 rii->details.amount = *credit;
1497 rii->details.execution_date = execution_date; 1498 rii->details.execution_date = execution_date;
1498 rii->details.reserve_pub = *reserve_pub; 1499 rii->details.reserve_pub = *reserve_pub;
1499 rii->details.debit_account_url = (const char *) &rii[1]; 1500 rii->details.debit_account_uri = (const char *) &rii[1];
1500 memcpy (&rii[1], 1501 memcpy (&rii[1],
1501 sender_account_details, 1502 sender_account_details,
1502 slen); 1503 slen);
@@ -1752,8 +1753,8 @@ history_credit_cb (void *cls,
1752 } 1753 }
1753 goto cleanup; 1754 goto cleanup;
1754 } 1755 }
1755 if (0 != strcasecmp (details->debit_account_url, 1756 if (0 != strcasecmp (details->debit_account_uri,
1756 rii->details.debit_account_url)) 1757 rii->details.debit_account_uri))
1757 { 1758 {
1758 TALER_ARL_report (report_missattribution_in_inconsistencies, 1759 TALER_ARL_report (report_missattribution_in_inconsistencies,
1759 GNUNET_JSON_PACK ( 1760 GNUNET_JSON_PACK (
@@ -1843,6 +1844,7 @@ process_credits (void *cls)
1843 wa->ai->auth, 1844 wa->ai->auth,
1844 wa->in_wire_off, 1845 wa->in_wire_off,
1845 INT64_MAX, 1846 INT64_MAX,
1847 GNUNET_TIME_UNIT_ZERO,
1846 &history_credit_cb, 1848 &history_credit_cb,
1847 wa); 1849 wa);
1848 if (NULL == wa->chh) 1850 if (NULL == wa->chh)
diff --git a/src/bank-lib/Makefile.am b/src/bank-lib/Makefile.am
index ef15a42d8..ffd428a6f 100644
--- a/src/bank-lib/Makefile.am
+++ b/src/bank-lib/Makefile.am
@@ -14,6 +14,7 @@ taler_fakebank_run_SOURCES = \
14 taler-fakebank-run.c 14 taler-fakebank-run.c
15taler_fakebank_run_LDADD = \ 15taler_fakebank_run_LDADD = \
16 libtalerfakebank.la \ 16 libtalerfakebank.la \
17 $(top_builddir)/src/mhd/libtalermhd.la \
17 $(top_builddir)/src/util/libtalerutil.la \ 18 $(top_builddir)/src/util/libtalerutil.la \
18 -lgnunetutil 19 -lgnunetutil
19 20
diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c
index 095cc379c..91fbe506d 100644
--- a/src/bank-lib/bank_api_credit.c
+++ b/src/bank-lib/bank_api_credit.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2017--2020 Taler Systems SA 3 Copyright (C) 2017--2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or 5 TALER is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License 6 modify it under the terms of the GNU General Public License
@@ -97,9 +97,9 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
97 GNUNET_JSON_spec_fixed_auto ("reserve_pub", 97 GNUNET_JSON_spec_fixed_auto ("reserve_pub",
98 &td.reserve_pub), 98 &td.reserve_pub),
99 GNUNET_JSON_spec_string ("debit_account", 99 GNUNET_JSON_spec_string ("debit_account",
100 &td.debit_account_url), 100 &td.debit_account_uri),
101 GNUNET_JSON_spec_string ("credit_account", 101 GNUNET_JSON_spec_string ("credit_account",
102 &td.credit_account_url), 102 &td.credit_account_uri),
103 GNUNET_JSON_spec_end () 103 GNUNET_JSON_spec_end ()
104 }; 104 };
105 json_t *transaction = json_array_get (history_array, 105 json_t *transaction = json_array_get (history_array,
@@ -217,12 +217,14 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
217 const struct TALER_BANK_AuthenticationData *auth, 217 const struct TALER_BANK_AuthenticationData *auth,
218 uint64_t start_row, 218 uint64_t start_row,
219 int64_t num_results, 219 int64_t num_results,
220 struct GNUNET_TIME_Relative timeout,
220 TALER_BANK_CreditHistoryCallback hres_cb, 221 TALER_BANK_CreditHistoryCallback hres_cb,
221 void *hres_cb_cls) 222 void *hres_cb_cls)
222{ 223{
223 char url[128]; 224 char url[128];
224 struct TALER_BANK_CreditHistoryHandle *hh; 225 struct TALER_BANK_CreditHistoryHandle *hh;
225 CURL *eh; 226 CURL *eh;
227 unsigned long long tms;
226 228
227 if (0 == num_results) 229 if (0 == num_results)
228 { 230 {
@@ -230,20 +232,43 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
230 return NULL; 232 return NULL;
231 } 233 }
232 234
235 tms = (unsigned long long) (timeout.rel_value_us
236 / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
233 if ( ( (UINT64_MAX == start_row) && 237 if ( ( (UINT64_MAX == start_row) &&
234 (0 > num_results) ) || 238 (0 > num_results) ) ||
235 ( (0 == start_row) && 239 ( (0 == start_row) &&
236 (0 < num_results) ) ) 240 (0 < num_results) ) )
237 GNUNET_snprintf (url, 241 {
238 sizeof (url), 242 if ( (0 < num_results) &&
239 "history/incoming?delta=%lld", 243 (! GNUNET_TIME_relative_is_zero (timeout)) )
240 (long long) num_results); 244 GNUNET_snprintf (url,
245 sizeof (url),
246 "history/incoming?delta=%lld&long_poll_ms=%llu",
247 (long long) num_results,
248 tms);
249 else
250 GNUNET_snprintf (url,
251 sizeof (url),
252 "history/incoming?delta=%lld",
253 (long long) num_results);
254 }
241 else 255 else
242 GNUNET_snprintf (url, 256 {
243 sizeof (url), 257 if ( (0 < num_results) &&
244 "history/incoming?delta=%lld&start=%llu", 258 (! GNUNET_TIME_relative_is_zero (timeout)) )
245 (long long) num_results, 259 GNUNET_snprintf (url,
246 (unsigned long long) start_row); 260 sizeof (url),
261 "history/incoming?delta=%lld&start=%llu&long_poll_ms=%llu",
262 (long long) num_results,
263 (unsigned long long) start_row,
264 tms);
265 else
266 GNUNET_snprintf (url,
267 sizeof (url),
268 "history/incoming?delta=%lld&start=%llu",
269 (long long) num_results,
270 (unsigned long long) start_row);
271 }
247 hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle); 272 hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle);
248 hh->hcb = hres_cb; 273 hh->hcb = hres_cb;
249 hh->hcb_cls = hres_cb_cls; 274 hh->hcb_cls = hres_cb_cls;
@@ -275,6 +300,13 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
275 curl_easy_cleanup (eh); 300 curl_easy_cleanup (eh);
276 return NULL; 301 return NULL;
277 } 302 }
303 if (0 != tms)
304 {
305 GNUNET_break (CURLE_OK ==
306 curl_easy_setopt (eh,
307 CURLOPT_TIMEOUT_MS,
308 (long) tms));
309 }
278 hh->job = GNUNET_CURL_job_add2 (ctx, 310 hh->job = GNUNET_CURL_job_add2 (ctx,
279 eh, 311 eh,
280 NULL, 312 NULL,
diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c
index 0e1ec0c5d..8cca0cc50 100644
--- a/src/bank-lib/bank_api_debit.c
+++ b/src/bank-lib/bank_api_debit.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2017--2020 Taler Systems SA 3 Copyright (C) 2017--2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or 5 TALER is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License 6 modify it under the terms of the GNU General Public License
@@ -97,9 +97,9 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh,
97 GNUNET_JSON_spec_fixed_auto ("wtid", 97 GNUNET_JSON_spec_fixed_auto ("wtid",
98 &td.wtid), 98 &td.wtid),
99 GNUNET_JSON_spec_string ("credit_account", 99 GNUNET_JSON_spec_string ("credit_account",
100 &td.credit_account_url), 100 &td.credit_account_uri),
101 GNUNET_JSON_spec_string ("debit_account", 101 GNUNET_JSON_spec_string ("debit_account",
102 &td.debit_account_url), 102 &td.debit_account_uri),
103 GNUNET_JSON_spec_string ("exchange_base_url", 103 GNUNET_JSON_spec_string ("exchange_base_url",
104 &td.exchange_base_url), 104 &td.exchange_base_url),
105 GNUNET_JSON_spec_end () 105 GNUNET_JSON_spec_end ()
@@ -214,35 +214,19 @@ handle_debit_history_finished (void *cls,
214} 214}
215 215
216 216
217/**
218 * Request the debit history of the exchange's bank account.
219 *
220 * @param ctx curl context for the event loop
221 * @param auth authentication data to use
222 * @param start_row from which row on do we want to get results,
223 * use UINT64_MAX for the latest; exclusive
224 * @param num_results how many results do we want;
225 * negative numbers to go into the past, positive numbers
226 * to go into the future starting at @a start_row;
227 * must not be zero.
228 * @param hres_cb the callback to call with the transaction
229 * history
230 * @param hres_cb_cls closure for the above callback
231 * @return NULL if the inputs are invalid (i.e. zero value for
232 * @e num_results). In this case, the callback is not
233 * called.
234 */
235struct TALER_BANK_DebitHistoryHandle * 217struct TALER_BANK_DebitHistoryHandle *
236TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx, 218TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
237 const struct TALER_BANK_AuthenticationData *auth, 219 const struct TALER_BANK_AuthenticationData *auth,
238 uint64_t start_row, 220 uint64_t start_row,
239 int64_t num_results, 221 int64_t num_results,
222 struct GNUNET_TIME_Relative timeout,
240 TALER_BANK_DebitHistoryCallback hres_cb, 223 TALER_BANK_DebitHistoryCallback hres_cb,
241 void *hres_cb_cls) 224 void *hres_cb_cls)
242{ 225{
243 char url[128]; 226 char url[128];
244 struct TALER_BANK_DebitHistoryHandle *hh; 227 struct TALER_BANK_DebitHistoryHandle *hh;
245 CURL *eh; 228 CURL *eh;
229 unsigned long long tms;
246 230
247 if (0 == num_results) 231 if (0 == num_results)
248 { 232 {
@@ -250,20 +234,43 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
250 return NULL; 234 return NULL;
251 } 235 }
252 236
237 tms = (unsigned long long) (timeout.rel_value_us
238 / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
253 if ( ( (UINT64_MAX == start_row) && 239 if ( ( (UINT64_MAX == start_row) &&
254 (0 > num_results) ) || 240 (0 > num_results) ) ||
255 ( (0 == start_row) && 241 ( (0 == start_row) &&
256 (0 < num_results) ) ) 242 (0 < num_results) ) )
257 GNUNET_snprintf (url, 243 {
258 sizeof (url), 244 if ( (0 < num_results) &&
259 "history/outgoing?delta=%lld", 245 (! GNUNET_TIME_relative_is_zero (timeout)) )
260 (long long) num_results); 246 GNUNET_snprintf (url,
247 sizeof (url),
248 "history/outgoing?delta=%lld&long_poll_ms=%llu",
249 (long long) num_results,
250 tms);
251 else
252 GNUNET_snprintf (url,
253 sizeof (url),
254 "history/outgoing?delta=%lld",
255 (long long) num_results);
256 }
261 else 257 else
262 GNUNET_snprintf (url, 258 {
263 sizeof (url), 259 if ( (0 < num_results) &&
264 "history/outgoing?delta=%lld&start=%llu", 260 (! GNUNET_TIME_relative_is_zero (timeout)) )
265 (long long) num_results, 261 GNUNET_snprintf (url,
266 (unsigned long long) start_row); 262 sizeof (url),
263 "history/outgoing?delta=%lld&start=%llu&long_poll_ms=%llu",
264 (long long) num_results,
265 (unsigned long long) start_row,
266 tms);
267 else
268 GNUNET_snprintf (url,
269 sizeof (url),
270 "history/outgoing?delta=%lld&start=%llu",
271 (long long) num_results,
272 (unsigned long long) start_row);
273 }
267 hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle); 274 hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle);
268 hh->hcb = hres_cb; 275 hh->hcb = hres_cb;
269 hh->hcb_cls = hres_cb_cls; 276 hh->hcb_cls = hres_cb_cls;
@@ -295,6 +302,13 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
295 curl_easy_cleanup (eh); 302 curl_easy_cleanup (eh);
296 return NULL; 303 return NULL;
297 } 304 }
305 if (0 != tms)
306 {
307 GNUNET_break (CURLE_OK ==
308 curl_easy_setopt (eh,
309 CURLOPT_TIMEOUT_MS,
310 (long) tms));
311 }
298 hh->job = GNUNET_CURL_job_add2 (ctx, 312 hh->job = GNUNET_CURL_job_add2 (ctx,
299 eh, 313 eh,
300 NULL, 314 NULL,
@@ -304,13 +318,6 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
304} 318}
305 319
306 320
307/**
308 * Cancel a history request. This function cannot be
309 * used on a request handle if a response is already
310 * served for it.
311 *
312 * @param hh the history request handle
313 */
314void 321void
315TALER_BANK_debit_history_cancel (struct TALER_BANK_DebitHistoryHandle *hh) 322TALER_BANK_debit_history_cancel (struct TALER_BANK_DebitHistoryHandle *hh)
316{ 323{
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 8c5a90fec..7c5a95ad6 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -321,11 +321,6 @@ struct TALER_FAKEBANK_Handle
321 */ 321 */
322 uint16_t port; 322 uint16_t port;
323 323
324 /**
325 * Force closing connections after each request.
326 */
327 bool force_close;
328
329#if EPOLL_SUPPORT 324#if EPOLL_SUPPORT
330 /** 325 /**
331 * Boxed @e mhd_fd. 326 * Boxed @e mhd_fd.
@@ -1968,8 +1963,7 @@ TALER_FAKEBANK_start (uint16_t port,
1968 return TALER_FAKEBANK_start2 (port, 1963 return TALER_FAKEBANK_start2 (port,
1969 currency, 1964 currency,
1970 65536, /* RAM limit */ 1965 65536, /* RAM limit */
1971 1, /* number of threads */ 1966 1);
1972 false);
1973} 1967}
1974 1968
1975 1969
@@ -1977,8 +1971,7 @@ struct TALER_FAKEBANK_Handle *
1977TALER_FAKEBANK_start2 (uint16_t port, 1971TALER_FAKEBANK_start2 (uint16_t port,
1978 const char *currency, 1972 const char *currency,
1979 uint64_t ram_limit, 1973 uint64_t ram_limit,
1980 unsigned int num_threads, 1974 unsigned int num_threads)
1981 bool close_connections)
1982{ 1975{
1983 struct TALER_FAKEBANK_Handle *h; 1976 struct TALER_FAKEBANK_Handle *h;
1984 1977
@@ -1992,7 +1985,6 @@ TALER_FAKEBANK_start2 (uint16_t port,
1992 GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN); 1985 GNUNET_assert (strlen (currency) < TALER_CURRENCY_LEN);
1993 h = GNUNET_new (struct TALER_FAKEBANK_Handle); 1986 h = GNUNET_new (struct TALER_FAKEBANK_Handle);
1994 h->port = port; 1987 h->port = port;
1995 h->force_close = close_connections;
1996 h->ram_limit = ram_limit; 1988 h->ram_limit = ram_limit;
1997 h->serial_counter = 0; 1989 h->serial_counter = 0;
1998 GNUNET_assert (0 == 1990 GNUNET_assert (0 ==
diff --git a/src/bank-lib/taler-exchange-wire-gateway-client.c b/src/bank-lib/taler-exchange-wire-gateway-client.c
index 436d416d5..47df82a8f 100644
--- a/src/bank-lib/taler-exchange-wire-gateway-client.c
+++ b/src/bank-lib/taler-exchange-wire-gateway-client.c
@@ -215,18 +215,18 @@ credit_history_cb (void *cls,
215 /* If credit/debit accounts were specified, use as a filter */ 215 /* If credit/debit accounts were specified, use as a filter */
216 if ( (NULL != credit_account) && 216 if ( (NULL != credit_account) &&
217 (0 != strcasecmp (credit_account, 217 (0 != strcasecmp (credit_account,
218 details->credit_account_url) ) ) 218 details->credit_account_uri) ) )
219 return GNUNET_OK; 219 return GNUNET_OK;
220 if ( (NULL != debit_account) && 220 if ( (NULL != debit_account) &&
221 (0 != strcasecmp (debit_account, 221 (0 != strcasecmp (debit_account,
222 details->debit_account_url) ) ) 222 details->debit_account_uri) ) )
223 return GNUNET_OK; 223 return GNUNET_OK;
224 224
225 fprintf (stdout, 225 fprintf (stdout,
226 "%llu: %s->%s (%s) over %s at %s\n", 226 "%llu: %s->%s (%s) over %s at %s\n",
227 (unsigned long long) serial_id, 227 (unsigned long long) serial_id,
228 details->debit_account_url, 228 details->debit_account_uri,
229 details->credit_account_url, 229 details->credit_account_uri,
230 TALER_B2S (&details->reserve_pub), 230 TALER_B2S (&details->reserve_pub),
231 TALER_amount2s (&details->amount), 231 TALER_amount2s (&details->amount),
232 GNUNET_STRINGS_absolute_time_to_string (details->execution_date)); 232 GNUNET_STRINGS_absolute_time_to_string (details->execution_date));
@@ -252,6 +252,7 @@ execute_credit_history (void)
252 &auth, 252 &auth,
253 start_row, 253 start_row,
254 -10, 254 -10,
255 GNUNET_TIME_UNIT_ZERO,
255 &credit_history_cb, 256 &credit_history_cb,
256 NULL); 257 NULL);
257 if (NULL == chh) 258 if (NULL == chh)
@@ -329,18 +330,18 @@ debit_history_cb (void *cls,
329 /* If credit/debit accounts were specified, use as a filter */ 330 /* If credit/debit accounts were specified, use as a filter */
330 if ( (NULL != credit_account) && 331 if ( (NULL != credit_account) &&
331 (0 != strcasecmp (credit_account, 332 (0 != strcasecmp (credit_account,
332 details->credit_account_url) ) ) 333 details->credit_account_uri) ) )
333 return GNUNET_OK; 334 return GNUNET_OK;
334 if ( (NULL != debit_account) && 335 if ( (NULL != debit_account) &&
335 (0 != strcasecmp (debit_account, 336 (0 != strcasecmp (debit_account,
336 details->debit_account_url) ) ) 337 details->debit_account_uri) ) )
337 return GNUNET_OK; 338 return GNUNET_OK;
338 339
339 fprintf (stdout, 340 fprintf (stdout,
340 "%llu: %s->%s (%s) over %s at %s\n", 341 "%llu: %s->%s (%s) over %s at %s\n",
341 (unsigned long long) serial_id, 342 (unsigned long long) serial_id,
342 details->debit_account_url, 343 details->debit_account_uri,
343 details->credit_account_url, 344 details->credit_account_uri,
344 TALER_B2S (&details->wtid), 345 TALER_B2S (&details->wtid),
345 TALER_amount2s (&details->amount), 346 TALER_amount2s (&details->amount),
346 GNUNET_STRINGS_absolute_time_to_string (details->execution_date)); 347 GNUNET_STRINGS_absolute_time_to_string (details->execution_date));
@@ -366,6 +367,7 @@ execute_debit_history (void)
366 &auth, 367 &auth,
367 start_row, 368 start_row,
368 -10, 369 -10,
370 GNUNET_TIME_UNIT_ZERO,
369 &debit_history_cb, 371 &debit_history_cb,
370 NULL); 372 NULL);
371 if (NULL == dhh) 373 if (NULL == dhh)
diff --git a/src/bank-lib/taler-fakebank-run.c b/src/bank-lib/taler-fakebank-run.c
index ff9dcc17c..282e39501 100644
--- a/src/bank-lib/taler-fakebank-run.c
+++ b/src/bank-lib/taler-fakebank-run.c
@@ -23,9 +23,9 @@
23 * @author Marcello Stanisci 23 * @author Marcello Stanisci
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
27#include "platform.h" 26#include "platform.h"
28#include "taler_fakebank_lib.h" 27#include "taler_fakebank_lib.h"
28#include "taler_mhd_lib.h"
29 29
30/** 30/**
31 * Number of threads to use (-n) 31 * Number of threads to use (-n)
@@ -111,11 +111,18 @@ run (void *cls,
111 "Maximum transaction history in RAM set to default of %llu\n", 111 "Maximum transaction history in RAM set to default of %llu\n",
112 ram); 112 ram);
113 } 113 }
114 {
115 enum TALER_MHD_GlobalOptions go;
116
117 go = TALER_MHD_GO_NONE;
118 if (0 != connection_close)
119 go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
120 TALER_MHD_setup (go);
121 }
114 fb = TALER_FAKEBANK_start2 ((uint16_t) port, 122 fb = TALER_FAKEBANK_start2 ((uint16_t) port,
115 currency_string, 123 currency_string,
116 ram, 124 ram,
117 num_threads, 125 num_threads);
118 (0 != connection_close));
119 if (NULL == fb) 126 if (NULL == fb)
120 { 127 {
121 ret = EXIT_FAILURE; 128 ret = EXIT_FAILURE;
diff --git a/src/benchmark/taler-bank-benchmark.c b/src/benchmark/taler-bank-benchmark.c
index f6c079e7f..b7bcc105c 100644
--- a/src/benchmark/taler-bank-benchmark.c
+++ b/src/benchmark/taler-bank-benchmark.c
@@ -443,8 +443,7 @@ launch_fakebank (void *cls)
443 = TALER_FAKEBANK_start2 ((uint16_t) pnum, 443 = TALER_FAKEBANK_start2 ((uint16_t) pnum,
444 currency, 444 currency,
445 history_size, 445 history_size,
446 howmany_threads, 446 howmany_threads);
447 false);
448 if (NULL == fakebank) 447 if (NULL == fakebank)
449 { 448 {
450 GNUNET_break (0); 449 GNUNET_break (0);
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index cc99e42c3..2993999a8 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -31,6 +31,12 @@
31 31
32 32
33/** 33/**
34 * How long to wait for an HTTP reply if there
35 * are no transactions pending at the server?
36 */
37#define LONGPOLL_TIMEOUT GNUNET_TIME_UNIT_MINUTES
38
39/**
34 * What is the maximum batch size we use for credit history 40 * What is the maximum batch size we use for credit history
35 * requests with the bank. See `batch_size` below. 41 * requests with the bank. See `batch_size` below.
36 */ 42 */
@@ -545,7 +551,7 @@ history_cb (void *cls,
545 &details->reserve_pub, 551 &details->reserve_pub,
546 &details->amount, 552 &details->amount,
547 details->execution_date, 553 details->execution_date,
548 details->debit_account_url, 554 details->debit_account_uri,
549 wa->ai->section_name, 555 wa->ai->section_name,
550 serial_id); 556 serial_id);
551 switch (qs) 557 switch (qs)
@@ -674,6 +680,9 @@ find_transfers (void *cls)
674 wa_pos->ai->auth, 680 wa_pos->ai->auth,
675 wa_pos->batch_start, 681 wa_pos->batch_start,
676 limit, 682 limit,
683 test_mode
684 ? GNUNET_TIME_UNIT_ZERO
685 : LONGPOLL_TIMEOUT,
677 &history_cb, 686 &history_cb,
678 wa_pos); 687 wa_pos);
679 if (NULL == wa_pos->hh) 688 if (NULL == wa_pos->hh)
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index 32a730b8e..db78ca6a8 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2015-2020 Taler Systems SA 3 Copyright (C) 2015-2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify it under the 5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU Affero General Public License as published by the Free Software 6 terms of the GNU Affero General Public License as published by the Free Software
@@ -278,13 +278,13 @@ struct TALER_BANK_CreditDetails
278 * payto://-URL of the source account that 278 * payto://-URL of the source account that
279 * send the funds. 279 * send the funds.
280 */ 280 */
281 const char *debit_account_url; 281 const char *debit_account_uri;
282 282
283 /** 283 /**
284 * payto://-URL of the target account that 284 * payto://-URL of the target account that
285 * received the funds. 285 * received the funds.
286 */ 286 */
287 const char *credit_account_url; 287 const char *credit_account_uri;
288}; 288};
289 289
290 290
@@ -323,6 +323,8 @@ typedef enum GNUNET_GenericReturnValue
323 * @param num_results how many results do we want; negative numbers to go into the past, 323 * @param num_results how many results do we want; negative numbers to go into the past,
324 * positive numbers to go into the future starting at @a start_row; 324 * positive numbers to go into the future starting at @a start_row;
325 * must not be zero. 325 * must not be zero.
326 * @param timeout how long the client is willing to wait for more results
327 * (only useful if @a num_results is positive)
326 * @param hres_cb the callback to call with the transaction history 328 * @param hres_cb the callback to call with the transaction history
327 * @param hres_cb_cls closure for the above callback 329 * @param hres_cb_cls closure for the above callback
328 * @return NULL 330 * @return NULL
@@ -334,6 +336,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
334 const struct TALER_BANK_AuthenticationData *auth, 336 const struct TALER_BANK_AuthenticationData *auth,
335 uint64_t start_row, 337 uint64_t start_row,
336 int64_t num_results, 338 int64_t num_results,
339 struct GNUNET_TIME_Relative timeout,
337 TALER_BANK_CreditHistoryCallback hres_cb, 340 TALER_BANK_CreditHistoryCallback hres_cb,
338 void *hres_cb_cls); 341 void *hres_cb_cls);
339 342
@@ -387,13 +390,13 @@ struct TALER_BANK_DebitDetails
387 * payto://-URI of the source account that 390 * payto://-URI of the source account that
388 * send the funds. 391 * send the funds.
389 */ 392 */
390 const char *debit_account_url; // FIXME: rename: url->uri 393 const char *debit_account_uri;
391 394
392 /** 395 /**
393 * payto://-URI of the target account that 396 * payto://-URI of the target account that
394 * received the funds. 397 * received the funds.
395 */ 398 */
396 const char *credit_account_url; // FIXME: rename: url->uri 399 const char *credit_account_uri;
397 400
398}; 401};
399 402
@@ -433,6 +436,8 @@ typedef enum GNUNET_GenericReturnValue
433 * @param num_results how many results do we want; negative numbers to go into the past, 436 * @param num_results how many results do we want; negative numbers to go into the past,
434 * positive numbers to go into the future starting at @a start_row; 437 * positive numbers to go into the future starting at @a start_row;
435 * must not be zero. 438 * must not be zero.
439 * @param timeout how long the client is willing to wait for more results
440 * (only useful if @a num_results is positive)
436 * @param hres_cb the callback to call with the transaction history 441 * @param hres_cb the callback to call with the transaction history
437 * @param hres_cb_cls closure for the above callback 442 * @param hres_cb_cls closure for the above callback
438 * @return NULL 443 * @return NULL
@@ -444,6 +449,7 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
444 const struct TALER_BANK_AuthenticationData *auth, 449 const struct TALER_BANK_AuthenticationData *auth,
445 uint64_t start_row, 450 uint64_t start_row,
446 int64_t num_results, 451 int64_t num_results,
452 struct GNUNET_TIME_Relative timeout,
447 TALER_BANK_DebitHistoryCallback hres_cb, 453 TALER_BANK_DebitHistoryCallback hres_cb,
448 void *hres_cb_cls); 454 void *hres_cb_cls);
449 455
diff --git a/src/include/taler_fakebank_lib.h b/src/include/taler_fakebank_lib.h
index 375bc9aa5..dc6ba1dac 100644
--- a/src/include/taler_fakebank_lib.h
+++ b/src/include/taler_fakebank_lib.h
@@ -66,15 +66,13 @@ TALER_FAKEBANK_start (uint16_t port,
66 * @param currency which currency should the bank offer 66 * @param currency which currency should the bank offer
67 * @param ram_limit how much memory do we use at most 67 * @param ram_limit how much memory do we use at most
68 * @param num_threads size of the thread pool, 0 to use the GNUnet scheduler 68 * @param num_threads size of the thread pool, 0 to use the GNUnet scheduler
69 * @param close_connections true to force closing a connection after each request (no HTTP keep-alive)
70 * @return NULL on error 69 * @return NULL on error
71 */ 70 */
72struct TALER_FAKEBANK_Handle * 71struct TALER_FAKEBANK_Handle *
73TALER_FAKEBANK_start2 (uint16_t port, 72TALER_FAKEBANK_start2 (uint16_t port,
74 const char *currency, 73 const char *currency,
75 uint64_t ram_limit, 74 uint64_t ram_limit,
76 unsigned int num_threads, 75 unsigned int num_threads);
77 bool close_connections);
78 76
79 77
80/** 78/**
diff --git a/src/testing/testing_api_cmd_bank_history_credit.c b/src/testing/testing_api_cmd_bank_history_credit.c
index 069f62cb0..c052b55fb 100644
--- a/src/testing/testing_api_cmd_bank_history_credit.c
+++ b/src/testing/testing_api_cmd_bank_history_credit.c
@@ -164,7 +164,7 @@ print_expected (struct History *h,
164 TALER_amount2s (&h[i].details.amount), 164 TALER_amount2s (&h[i].details.amount),
165 (unsigned long long) h[i].row_id, 165 (unsigned long long) h[i].row_id,
166 TALER_B2S (&h[i].details.reserve_pub), 166 TALER_B2S (&h[i].details.reserve_pub),
167 h[i].details.debit_account_url); 167 h[i].details.debit_account_uri);
168 } 168 }
169} 169}
170 170
@@ -313,11 +313,11 @@ build_history (struct TALER_TESTING_Interpreter *is,
313 total, 313 total,
314 pos * 2); 314 pos * 2);
315 h[pos].url = GNUNET_strdup (debit_account); 315 h[pos].url = GNUNET_strdup (debit_account);
316 h[pos].details.debit_account_url = h[pos].url; 316 h[pos].details.debit_account_uri = h[pos].url;
317 h[pos].details.amount = *amount; 317 h[pos].details.amount = *amount;
318 h[pos].row_id = *row_id; 318 h[pos].row_id = *row_id;
319 h[pos].details.reserve_pub = *reserve_pub; 319 h[pos].details.reserve_pub = *reserve_pub;
320 h[pos].details.credit_account_url = exchange_credit_url; 320 h[pos].details.credit_account_uri = exchange_credit_url;
321 pos++; 321 pos++;
322 } 322 }
323 GNUNET_assert (GNUNET_YES == ok); 323 GNUNET_assert (GNUNET_YES == ok);
@@ -364,16 +364,16 @@ check_result (struct History *h,
364 &details->reserve_pub)) || 364 &details->reserve_pub)) ||
365 (0 != TALER_amount_cmp (&h[off].details.amount, 365 (0 != TALER_amount_cmp (&h[off].details.amount,
366 &details->amount)) || 366 &details->amount)) ||
367 (0 != strcasecmp (h[off].details.debit_account_url, 367 (0 != strcasecmp (h[off].details.debit_account_uri,
368 details->debit_account_url)) ) 368 details->debit_account_uri)) )
369 { 369 {
370 GNUNET_break (0); 370 GNUNET_break (0);
371 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 371 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
372 "expected debit_account_url: %s\n", 372 "expected debit_account_uri: %s\n",
373 details->debit_account_url); 373 details->debit_account_uri);
374 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 374 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
375 "actual debit_account_url: %s\n", 375 "actual debit_account_uri: %s\n",
376 h[off].details.debit_account_url); 376 h[off].details.debit_account_uri);
377 print_expected (h, 377 print_expected (h,
378 total, 378 total,
379 off); 379 off);
@@ -521,6 +521,7 @@ history_run (void *cls,
521 &hs->auth, 521 &hs->auth,
522 row_id, 522 row_id,
523 hs->num_results, 523 hs->num_results,
524 GNUNET_TIME_UNIT_ZERO,
524 &history_cb, 525 &history_cb,
525 is); 526 is);
526 GNUNET_assert (NULL != hs->hh); 527 GNUNET_assert (NULL != hs->hh);
@@ -554,23 +555,12 @@ history_cleanup (void *cls,
554} 555}
555 556
556 557
557/**
558 * Make a "history" CMD.
559 *
560 * @param label command label.
561 * @param auth authentication data to talk with the wire gateway
562 * @param start_row_reference reference to a command that can
563 * offer a row identifier, to be used as the starting row
564 * to accept in the result.
565 * @param num_results how many rows we want in the result.
566 * @return the command.
567 */
568struct TALER_TESTING_Command 558struct TALER_TESTING_Command
569TALER_TESTING_cmd_bank_credits (const char *label, 559TALER_TESTING_cmd_bank_credits (
570 const struct 560 const char *label,
571 TALER_BANK_AuthenticationData *auth, 561 const struct TALER_BANK_AuthenticationData *auth,
572 const char *start_row_reference, 562 const char *start_row_reference,
573 long long num_results) 563 long long num_results)
574{ 564{
575 struct HistoryState *hs; 565 struct HistoryState *hs;
576 566
diff --git a/src/testing/testing_api_cmd_bank_history_debit.c b/src/testing/testing_api_cmd_bank_history_debit.c
index fcc78bfb7..779facee8 100644
--- a/src/testing/testing_api_cmd_bank_history_debit.c
+++ b/src/testing/testing_api_cmd_bank_history_debit.c
@@ -167,7 +167,7 @@ print_expected (struct History *h,
167 TALER_amount2s (&h[i].details.amount), 167 TALER_amount2s (&h[i].details.amount),
168 (unsigned long long) h[i].row_id, 168 (unsigned long long) h[i].row_id,
169 TALER_B2S (&h[i].details.wtid), 169 TALER_B2S (&h[i].details.wtid),
170 h[i].details.credit_account_url); 170 h[i].details.credit_account_uri);
171 } 171 }
172} 172}
173 173
@@ -320,8 +320,8 @@ build_history (struct TALER_TESTING_Interpreter *is,
320 pos * 2); 320 pos * 2);
321 h[pos].c_url = GNUNET_strdup (credit_account); 321 h[pos].c_url = GNUNET_strdup (credit_account);
322 h[pos].d_url = GNUNET_strdup (debit_account); 322 h[pos].d_url = GNUNET_strdup (debit_account);
323 h[pos].details.credit_account_url = h[pos].c_url; 323 h[pos].details.credit_account_uri = h[pos].c_url;
324 h[pos].details.debit_account_url = h[pos].d_url; 324 h[pos].details.debit_account_uri = h[pos].d_url;
325 h[pos].details.amount = *amount; 325 h[pos].details.amount = *amount;
326 h[pos].row_id = *row_id; 326 h[pos].row_id = *row_id;
327 h[pos].details.wtid = *wtid; 327 h[pos].details.wtid = *wtid;
@@ -372,8 +372,8 @@ check_result (struct History *h,
372 &details->wtid)) || 372 &details->wtid)) ||
373 (0 != TALER_amount_cmp (&h[off].details.amount, 373 (0 != TALER_amount_cmp (&h[off].details.amount,
374 &details->amount)) || 374 &details->amount)) ||
375 (0 != strcasecmp (h[off].details.credit_account_url, 375 (0 != strcasecmp (h[off].details.credit_account_uri,
376 details->credit_account_url)) ) 376 details->credit_account_uri)) )
377 { 377 {
378 GNUNET_break (0); 378 GNUNET_break (0);
379 print_expected (h, 379 print_expected (h,
@@ -522,6 +522,7 @@ history_run (void *cls,
522 &hs->auth, 522 &hs->auth,
523 row_id, 523 row_id,
524 hs->num_results, 524 hs->num_results,
525 GNUNET_TIME_UNIT_ZERO,
525 &history_cb, 526 &history_cb,
526 is); 527 is);
527 GNUNET_assert (NULL != hs->hh); 528 GNUNET_assert (NULL != hs->hh);