aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-03-04 11:47:22 +0100
committerChristian Grothoff <christian@grothoff.org>2020-03-04 11:47:22 +0100
commit6cc516427b06f1fd1a72ee1b75da909e1ed38166 (patch)
treed1329c6f8a5cb3aeed9fdad1b57db56c30bde09b /src/exchangedb
parenta3013d9e3d26daf9f5df39046c6a9bc0dc45603b (diff)
minor code clean up, renaming for consistency
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/exchangedb_transactions.c2
-rw-r--r--src/exchangedb/plugin_exchangedb_common.c138
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c10
-rw-r--r--src/exchangedb/test_exchangedb.c2
4 files changed, 90 insertions, 62 deletions
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; i<num_results; i++)
{
- struct TALER_EXCHANGEDB_RefreshMeltListEntry *melt;
+ struct TALER_EXCHANGEDB_MeltListEntry *melt;
struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id;
- melt = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMeltListEntry);
+ melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("rc",
@@ -4119,7 +4119,7 @@ add_coin_melt (void *cls,
}
tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList);
tl->next = 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)));