merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit bbe200d9b5686db6dd8f33a0edd31324efc94ec6
parent a2aa45ff83d1340bb02e1153ae55f042e23ac3c2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 27 Apr 2025 22:21:00 +0200

nicer logging, do not run successful exchange keys update 3x for no reason

Diffstat:
Msrc/backend/taler-merchant-exchangekeyupdate.c | 14++++++++++++--
Msrc/backend/taler-merchant-httpd_exchanges.c | 6++++++
Msrc/backend/taler-merchant-httpd_post-orders-ID-pay.c | 7++++---
3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/backend/taler-merchant-exchangekeyupdate.c b/src/backend/taler-merchant-exchangekeyupdate.c @@ -424,6 +424,9 @@ insert_keys_data (const struct TALER_EXCHANGE_Keys *keys) .type = ntohs (TALER_DBEVENT_MERCHANT_EXCHANGE_KEYS) }; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Informing other processes about keys change for %s\n", + keys->exchange_url); db_plugin->event_notify (db_plugin->cls, &es, keys->exchange_url, @@ -459,7 +462,7 @@ store_keys (struct TALER_EXCHANGE_Keys *keys) } qs = insert_keys_data (keys); - if (qs < 0) + if (0 > qs) { db_plugin->rollback (db_plugin->cls); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -469,7 +472,7 @@ store_keys (struct TALER_EXCHANGE_Keys *keys) } qs = db_plugin->commit (db_plugin->cls); - if (qs < 0) + if (0 > qs) { db_plugin->rollback (db_plugin->cls); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -477,6 +480,7 @@ store_keys (struct TALER_EXCHANGE_Keys *keys) GNUNET_break (0); return false; } + break; } /* end of retry loop */ if (qs < 0) { @@ -528,8 +532,14 @@ cert_cb ( e->exchange_url); break; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Got new keys for %s, updating database\n", + e->exchange_url); if (! store_keys (keys)) + { + GNUNET_break (0); break; + } e->keys = TALER_EXCHANGE_keys_incref (keys); /* Reset back-off */ e->retry_delay = EXCHANGE_MAXFREQ; diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c @@ -520,6 +520,8 @@ TMH_EXCHANGES_keys4exchange ( (NULL != exchange->keys) ) { /* Return results immediately. */ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Earliest retry is in the future, returning keys now\n"); fo->at = GNUNET_SCHEDULER_add_now (&return_keys, fo); /* *no* return here, we MAY schedule a 'retry_task' in the @@ -901,6 +903,9 @@ reload_exchange_keys (struct TMH_Exchange *exchange) exchange->url); return; } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Loading latest keys of `%s' from database\n", + exchange->url); exchange->retry_delay = GNUNET_TIME_UNIT_ZERO; if (NULL == exchange->currency) exchange->currency = GNUNET_strdup (keys->currency); @@ -1191,6 +1196,7 @@ TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg) .type = ntohs (TALER_DBEVENT_MERCHANT_EXCHANGE_KEYS) }; + GNUNET_assert (NULL == keys_eh); keys_eh = TMH_db->event_listen (TMH_db->cls, &es, GNUNET_TIME_UNIT_FOREVER_REL, diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -1205,7 +1205,7 @@ process_pay_with_keys ( pc->batch_deposits.pending_at_eg--; GNUNET_SCHEDULER_begin_async_scope (&hc->async_scope_id); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Processing payment with exchange %s\n", + "Processing payment with keys from exchange %s\n", eg->exchange_url); GNUNET_assert (GNUNET_YES == pc->suspended); if (NULL == keys) @@ -1321,7 +1321,8 @@ process_pay_with_keys ( return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Have missing denomination for exchange, updating %s\n", + "Missing denomination %s from exchange %s, updating keys\n", + GNUNET_h2s (&dc->cdd.h_denom_pub.hash), eg->exchange_url); force_keys (eg); return; @@ -1509,7 +1510,7 @@ force_keys (struct ExchangeGroup *eg) eg->tried_force_keys = true; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Forcing /keys download (once) as wire fees are unknown\n"); + "Forcing /keys download (once)\n"); eg->fo = TMH_EXCHANGES_keys4exchange ( eg->exchange_url, true,