summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-08 15:53:48 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-08 15:53:48 +0200
commit1e2adf90d4e1239141426db76c50509751fc614f (patch)
tree6a06e8b869ffa9003f3d424497750a98fdcfe8cf
parentcac9a386127ce68c9c7a122623d7a3bbdf951029 (diff)
downloadmerchant-1e2adf90d4e1239141426db76c50509751fc614f.tar.gz
merchant-1e2adf90d4e1239141426db76c50509751fc614f.tar.bz2
merchant-1e2adf90d4e1239141426db76c50509751fc614f.zip
add loop over result of refunding information
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 15ebbf1e..526ba6e9 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1626,11 +1626,6 @@ postgres_increase_refund_for_contract (void *cls,
const struct TALER_Amount *refund,
const char *reason)
{
- /*FIXME, logic incomplete*/
-
- /* 1 Get coins for a given contract
- 2 "Spread" the refund amount among those coins
- 3 Store the solution into table merchant_refund */
struct PostgresClosure *pg = cls;
PGresult *result;
@@ -1652,6 +1647,41 @@ postgres_increase_refund_for_contract (void *cls,
return GNUNET_SYSERR;
}
+ /*FIXME, logic incomplete*/
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "increase DB routine\n");
+ for (i=0;i<PQntuples (result);i++)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "increase DB routine loop (%d)\n",
+ i);
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+ struct TALER_Amount amount_with_fee;
+ struct TALER_Amount refund_amount_awarded;
+
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("merchant_deposits.coin_pub",
+ &coin_pub),
+ TALER_PQ_result_spec_amount ("merchant_deposits.amount_with_fee",
+ &amount_with_fee),
+ TALER_PQ_result_spec_amount ("merchant_refunds.refund_amount",
+ &refund_amount_awarded),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ PQclear (result);
+ return GNUNET_SYSERR;
+ }
+
+ }
+
return GNUNET_OK;
}