minor code clean up, renaming for consistency

This commit is contained in:
Christian Grothoff 2020-03-04 11:47:22 +01:00
parent a3013d9e3d
commit 6cc516427b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 99 additions and 71 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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);

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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 */

View File

@ -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)));

View File

@ -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.