From 6cc516427b06f1fd1a72ee1b75da909e1ed38166 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 4 Mar 2020 11:47:22 +0100 Subject: [PATCH] minor code clean up, renaming for consistency --- src/auditor/taler-auditor.c | 2 +- src/exchange/taler-exchange-httpd_refund.c | 2 +- src/exchange/taler-exchange-httpd_responses.c | 4 +- src/exchangedb/exchangedb_transactions.c | 2 +- src/exchangedb/plugin_exchangedb_common.c | 138 +++++++++++------- src/exchangedb/plugin_exchangedb_postgres.c | 10 +- src/exchangedb/test_exchangedb.c | 2 +- src/include/taler_exchangedb_plugin.h | 10 +- 8 files changed, 99 insertions(+), 71 deletions(-) diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index 2d33987b3..add807f5e 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -2297,7 +2297,7 @@ check_transaction_history_for_deposit (const struct return GNUNET_SYSERR; } break; - case TALER_EXCHANGEDB_TT_REFRESH_MELT: + case TALER_EXCHANGEDB_TT_MELT: amount_with_fee = &tl->details.melt->amount_with_fee; fee = &tl->details.melt->melt_fee; fee_dki = &issue->fee_refresh; diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index e7e34e0ba..2bbab0418 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -202,7 +202,7 @@ refund_transaction (void *cls, } } break; - case TALER_EXCHANGEDB_TT_REFRESH_MELT: + case TALER_EXCHANGEDB_TT_MELT: /* Melts cannot be refunded, ignore here */ break; case TALER_EXCHANGEDB_TT_REFUND: diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index f2593672a..0e7704e47 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -125,10 +125,10 @@ TEH_RESPONSE_compile_transaction_history (const struct } break; } - case TALER_EXCHANGEDB_TT_REFRESH_MELT: + case TALER_EXCHANGEDB_TT_MELT: { struct TALER_RefreshMeltCoinAffirmationPS ms; - const struct TALER_EXCHANGEDB_RefreshMeltListEntry *melt = + const struct TALER_EXCHANGEDB_MeltListEntry *melt = pos->details.melt; ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c index 50e21f4d4..79acdb4a0 100644 --- a/src/exchangedb/exchangedb_transactions.c +++ b/src/exchangedb/exchangedb_transactions.c @@ -63,7 +63,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (struct return GNUNET_SYSERR; } break; - case TALER_EXCHANGEDB_TT_REFRESH_MELT: + case TALER_EXCHANGEDB_TT_MELT: /* spent += pos->amount_with_fee */ if (GNUNET_OK != TALER_amount_add (&spent, diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index 5c9ff7f50..448d45827 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015, 2016 Taler Systems SA + Copyright (C) 2015, 2016, 2020 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,42 +30,56 @@ static void common_free_reserve_history (void *cls, struct TALER_EXCHANGEDB_ReserveHistory *rh) { - struct TALER_EXCHANGEDB_BankTransfer *bt; - struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc; - struct TALER_EXCHANGEDB_Recoup *recoup; - struct TALER_EXCHANGEDB_ReserveHistory *backref; - struct TALER_EXCHANGEDB_ClosingTransfer *closing; - (void) cls; while (NULL != rh) { switch (rh->type) { case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE: - bt = rh->details.bank; - GNUNET_free_non_null (bt->sender_account_details); - GNUNET_free_non_null (bt->wire_reference); - GNUNET_free (bt); - break; + { + struct TALER_EXCHANGEDB_BankTransfer *bt; + + bt = rh->details.bank; + GNUNET_free_non_null (bt->sender_account_details); + GNUNET_free_non_null (bt->wire_reference); + GNUNET_free (bt); + break; + } case TALER_EXCHANGEDB_RO_WITHDRAW_COIN: - cbc = rh->details.withdraw; - GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature); - GNUNET_free (cbc); - break; + { + struct TALER_EXCHANGEDB_CollectableBlindcoin *cbc; + + cbc = rh->details.withdraw; + GNUNET_CRYPTO_rsa_signature_free (cbc->sig.rsa_signature); + GNUNET_free (cbc); + break; + } case TALER_EXCHANGEDB_RO_RECOUP_COIN: - recoup = rh->details.recoup; - GNUNET_CRYPTO_rsa_signature_free (recoup->coin.denom_sig.rsa_signature); - GNUNET_free (recoup); - break; + { + struct TALER_EXCHANGEDB_Recoup *recoup; + + recoup = rh->details.recoup; + GNUNET_CRYPTO_rsa_signature_free (recoup->coin.denom_sig.rsa_signature); + GNUNET_free (recoup); + break; + } case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK: - closing = rh->details.closing; - GNUNET_free_non_null (closing->receiver_account_details); - GNUNET_free (closing); - break; + { + struct TALER_EXCHANGEDB_ClosingTransfer *closing; + + closing = rh->details.closing; + GNUNET_free_non_null (closing->receiver_account_details); + GNUNET_free (closing); + break; + } + } + { + struct TALER_EXCHANGEDB_ReserveHistory *next; + + next = rh->next; + GNUNET_free (rh); + rh = next; } - backref = rh; - rh = rh->next; - GNUNET_free (backref); } } @@ -74,50 +88,64 @@ common_free_reserve_history (void *cls, * Free linked list of transactions. * * @param cls the @e cls of this struct with the plugin-specific state (unused) - * @param list list to free + * @param tl list to free */ static void common_free_coin_transaction_list (void *cls, - struct TALER_EXCHANGEDB_TransactionList *list) + struct TALER_EXCHANGEDB_TransactionList *tl) { - struct TALER_EXCHANGEDB_TransactionList *next; - (void) cls; - while (NULL != list) + while (NULL != tl) { - next = list->next; - - switch (list->type) + switch (tl->type) { case TALER_EXCHANGEDB_TT_DEPOSIT: - if (NULL != list->details.deposit->receiver_wire_account) - json_decref (list->details.deposit->receiver_wire_account); - GNUNET_free (list->details.deposit); - break; - case TALER_EXCHANGEDB_TT_REFRESH_MELT: - GNUNET_free (list->details.melt); + { + struct TALER_EXCHANGEDB_DepositListEntry *deposit; + + deposit = tl->details.deposit; + if (NULL != deposit->receiver_wire_account) + json_decref (deposit->receiver_wire_account); + GNUNET_free (deposit); + break; + } + case TALER_EXCHANGEDB_TT_MELT: + GNUNET_free (tl->details.melt); break; case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP: - if (NULL != list->details.recoup_refresh->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.recoup_refresh->coin.denom_sig.rsa_signature); - GNUNET_free (list->details.old_coin_recoup); - break; + { + struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr; + + rr = tl->details.old_coin_recoup; + if (NULL != rr->coin.denom_sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature); + GNUNET_free (rr); + break; + } case TALER_EXCHANGEDB_TT_REFUND: - GNUNET_free (list->details.refund); + GNUNET_free (tl->details.refund); break; case TALER_EXCHANGEDB_TT_RECOUP: - GNUNET_free (list->details.recoup); + GNUNET_free (tl->details.recoup); break; case TALER_EXCHANGEDB_TT_RECOUP_REFRESH: - if (NULL != list->details.recoup_refresh->coin.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free ( - list->details.recoup_refresh->coin.denom_sig.rsa_signature); - GNUNET_free (list->details.recoup_refresh); - break; + { + struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr; + + rr = tl->recoup_refresh; + if (NULL != rr->coin.denom_sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (rr->coin.denom_sig.rsa_signature); + GNUNET_free (rr); + break; + } + } + { + struct TALER_EXCHANGEDB_TransactionList *next; + + next = tl->next; + GNUNET_free (list); + tl = next; } - GNUNET_free (list); - list = next; } } diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index f8aea50c0..ac4f3598a 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -4085,11 +4085,11 @@ add_coin_melt (void *cls, for (unsigned int i = 0; inext = chc->head; - tl->type = TALER_EXCHANGEDB_TT_REFRESH_MELT; + tl->type = TALER_EXCHANGEDB_TT_MELT; tl->details.melt = melt; tl->serial_id = serial_id; chc->head = tl; @@ -4426,7 +4426,7 @@ postgres_get_coin_transactions (void *cls, /** #TALER_EXCHANGEDB_TT_DEPOSIT */ { "get_deposit_with_coin_pub", &add_coin_deposit }, - /** #TALER_EXCHANGEDB_TT_REFRESH_MELT */ + /** #TALER_EXCHANGEDB_TT_MELT */ { "get_refresh_session_by_coin", &add_coin_melt }, /** #TALER_EXCHANGEDB_TT_REFUND */ @@ -4438,7 +4438,7 @@ postgres_get_coin_transactions (void *cls, /** #TALER_EXCHANGEDB_TT_DEPOSIT */ { "get_deposit_with_coin_pub", &add_coin_deposit }, - /** #TALER_EXCHANGEDB_TT_REFRESH_MELT */ + /** #TALER_EXCHANGEDB_TT_MELT */ { "get_refresh_session_by_coin", &add_coin_melt }, /** #TALER_EXCHANGEDB_TT_REFUND */ diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 1e0dfbffc..b52055996 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -2067,7 +2067,7 @@ run (void *cls) } #if 0 /* this coin pub was actually never melted... */ - case TALER_EXCHANGEDB_TT_REFRESH_MELT: + case TALER_EXCHANGEDB_TT_MELT: FAILIF (0 != memcmp (&melt, &tlp->details.melt, sizeof (struct TALER_EXCHANGEDB_RefreshMelt))); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 754ac1ef6..795c6d7be 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -766,9 +766,9 @@ struct TALER_EXCHANGEDB_RefreshSession /** - * Information about a /refresh/melt operation in a coin transaction history. + * Information about a /coins/$COIN_PUB/melt operation in a coin transaction history. */ -struct TALER_EXCHANGEDB_RefreshMeltListEntry +struct TALER_EXCHANGEDB_MeltListEntry { /** @@ -867,7 +867,7 @@ enum TALER_EXCHANGEDB_TransactionType /** * /refresh/melt operation. */ - TALER_EXCHANGEDB_TT_REFRESH_MELT = 1, + TALER_EXCHANGEDB_TT_MELT = 1, /** * /refund operation. @@ -927,9 +927,9 @@ struct TALER_EXCHANGEDB_TransactionList /** * Details if transaction was a /refresh/melt operation. - * (#TALER_EXCHANGEDB_TT_REFRESH_MELT) + * (#TALER_EXCHANGEDB_TT_MELT) */ - struct TALER_EXCHANGEDB_RefreshMeltListEntry *melt; + struct TALER_EXCHANGEDB_MeltListEntry *melt; /** * Details if transaction was a /refund operation.