aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-24 00:52:33 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-24 00:52:33 +0200
commit6772037321c96aed73e898e3328286c219bcf7c8 (patch)
treef614b63f7788b38140433f7d960b7ddb98ee79b6
parentde61e06eb164c5cb05778aba8e448a001462b783 (diff)
downloadexchange-6772037321c96aed73e898e3328286c219bcf7c8.tar.gz
exchange-6772037321c96aed73e898e3328286c219bcf7c8.zip
fix invariant check
-rw-r--r--src/exchangedb/exchangedb_transactions.c9
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c9
2 files changed, 10 insertions, 8 deletions
diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c
index 93e4104e6..c1723958f 100644
--- a/src/exchangedb/exchangedb_transactions.c
+++ b/src/exchangedb/exchangedb_transactions.c
@@ -42,13 +42,13 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
42 struct TALER_Amount refunded; 42 struct TALER_Amount refunded;
43 struct TALER_Amount deposit_fee; 43 struct TALER_Amount deposit_fee;
44 bool have_refund; 44 bool have_refund;
45 bool have_deposit; 45 bool have_deposit_or_melt;
46 46
47 GNUNET_assert (GNUNET_OK == 47 GNUNET_assert (GNUNET_OK ==
48 TALER_amount_get_zero (spent.currency, 48 TALER_amount_get_zero (spent.currency,
49 &refunded)); 49 &refunded));
50 have_refund = false; 50 have_refund = false;
51 have_deposit = false; 51 have_deposit_or_melt = false;
52 for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; 52 for (struct TALER_EXCHANGEDB_TransactionList *pos = tl;
53 NULL != pos; 53 NULL != pos;
54 pos = pos->next) 54 pos = pos->next)
@@ -57,7 +57,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
57 { 57 {
58 case TALER_EXCHANGEDB_TT_DEPOSIT: 58 case TALER_EXCHANGEDB_TT_DEPOSIT:
59 /* spent += pos->amount_with_fee */ 59 /* spent += pos->amount_with_fee */
60 have_deposit = true; 60 have_deposit_or_melt = true;
61 if (0 > 61 if (0 >
62 TALER_amount_add (&spent, 62 TALER_amount_add (&spent,
63 &spent, 63 &spent,
@@ -70,6 +70,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
70 break; 70 break;
71 case TALER_EXCHANGEDB_TT_MELT: 71 case TALER_EXCHANGEDB_TT_MELT:
72 /* spent += pos->amount_with_fee */ 72 /* spent += pos->amount_with_fee */
73 have_deposit_or_melt = true;
73 if (0 > 74 if (0 >
74 TALER_amount_add (&spent, 75 TALER_amount_add (&spent,
75 &spent, 76 &spent,
@@ -155,7 +156,7 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals (
155 GNUNET_break (0); 156 GNUNET_break (0);
156 return GNUNET_SYSERR; 157 return GNUNET_SYSERR;
157 } 158 }
158 GNUNET_break (have_deposit); 159 GNUNET_break (have_deposit_or_melt);
159 *ret = spent; 160 *ret = spent;
160 return GNUNET_OK; 161 return GNUNET_OK;
161} 162}
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index e517d069b..5bd674b2d 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -4006,9 +4006,9 @@ struct CoinHistoryContext
4006 bool failed; 4006 bool failed;
4007 4007
4008 /** 4008 /**
4009 * Set to 'true' if we found a deposit (for invariant check). 4009 * Set to 'true' if we found a deposit or melt (for invariant check).
4010 */ 4010 */
4011 bool have_deposit; 4011 bool have_deposit_or_melt;
4012}; 4012};
4013 4013
4014 4014
@@ -4034,7 +4034,7 @@ add_coin_deposit (void *cls,
4034 struct TALER_EXCHANGEDB_TransactionList *tl; 4034 struct TALER_EXCHANGEDB_TransactionList *tl;
4035 uint64_t serial_id; 4035 uint64_t serial_id;
4036 4036
4037 chc->have_deposit = true; 4037 chc->have_deposit_or_melt = true;
4038 deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry); 4038 deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
4039 { 4039 {
4040 struct GNUNET_PQ_ResultSpec rs[] = { 4040 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -4106,6 +4106,7 @@ add_coin_melt (void *cls,
4106 struct TALER_EXCHANGEDB_TransactionList *tl; 4106 struct TALER_EXCHANGEDB_TransactionList *tl;
4107 uint64_t serial_id; 4107 uint64_t serial_id;
4108 4108
4109 chc->have_deposit_or_melt = true;
4109 melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry); 4110 melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
4110 { 4111 {
4111 struct GNUNET_PQ_ResultSpec rs[] = { 4112 struct GNUNET_PQ_ResultSpec rs[] = {
@@ -4512,7 +4513,7 @@ postgres_get_coin_transactions (
4512 *tlp = chc.head; 4513 *tlp = chc.head;
4513 if (NULL == chc.head) 4514 if (NULL == chc.head)
4514 return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; 4515 return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
4515 GNUNET_break (chc.have_deposit); 4516 GNUNET_break (chc.have_deposit_or_melt);
4516 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; 4517 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
4517} 4518}
4518 4519