aboutsummaryrefslogtreecommitdiff
path: root/src/bank-lib/bank_api_credit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bank-lib/bank_api_credit.c')
-rw-r--r--src/bank-lib/bank_api_credit.c56
1 files changed, 44 insertions, 12 deletions
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,