summaryrefslogtreecommitdiff
path: root/src/backenddb/plugin_merchantdb_postgres.c
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-13 20:50:26 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-13 20:51:22 +0200
commitbd79ca83a26aec30d5b5e60ef573b56d5f8c8645 (patch)
tree7287d86e5ba9bf11cc986cd9bbbb9ee9a4e0dd6f /src/backenddb/plugin_merchantdb_postgres.c
parent6efeffdd62f2b599ffaf219e741592bcdd103b46 (diff)
downloadmerchant-bd79ca83a26aec30d5b5e60ef573b56d5f8c8645.tar.gz
merchant-bd79ca83a26aec30d5b5e60ef573b56d5f8c8645.tar.bz2
merchant-bd79ca83a26aec30d5b5e60ef573b56d5f8c8645.zip
- only commit refund if amount refunded per coin is > zero
- add valid second refund increasing
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 371cc4b5..dee509cd 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2002,22 +2002,24 @@ process_deposits_cb (void *cls,
/*Always commit the smallest as refund*/
- if (1 != insert_refund (ctx->pg,
- ctx->h_contract_terms,
- &coin_pub,
- ctx->reason,
- small))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not commit refund worth %s for coin '%s'"
- ", as of contract/reason: %s/%s\n",
- TALER_amount_to_string (small),
- TALER_B2S (&coin_pub),
- GNUNET_h2s (ctx->h_contract_terms),
- ctx->reason);
- ctx->err = GNUNET_SYSERR;
- return;
- }
+ if ( (0 != small->value) || (0 != small->fraction) )
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+ insert_refund (ctx->pg,
+ ctx->h_contract_terms,
+ &coin_pub,
+ ctx->reason,
+ small))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not commit refund worth %s for coin '%s'"
+ ", as of contract/reason: %s/%s\n",
+ TALER_amount_to_string (small),
+ TALER_B2S (&coin_pub),
+ GNUNET_h2s (ctx->h_contract_terms),
+ ctx->reason);
+ ctx->err = GNUNET_SYSERR;
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Detracting %s as refund, from coin %s\n",
@@ -2029,15 +2031,21 @@ process_deposits_cb (void *cls,
if ( (0 == ctx->refund->value) &&
(0 == ctx->refund->fraction) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All refund amount has been allocated\n");
break;
+ }
}
- if (-1 == TALER_amount_cmp (&attempted_refund, &previous_refund))
+ if (-1 == TALER_amount_cmp (&attempted_refund,
+ &previous_refund))
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Attempted refund lesser than the previous awarded one. %s vs %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Attempted refund lesser than the previous"
+ "awarded one. %s vs %s\n",
TALER_amount_to_string (&attempted_refund),
TALER_amount_to_string (&previous_refund));
ctx->err = GNUNET_NO;