gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: -fix full refund deposit fee com


From: gnunet
Subject: [taler-exchange] branch master updated: -fix full refund deposit fee computation in aggregator
Date: Sat, 09 Jul 2022 12:14:23 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 4e5193a2 -fix full refund deposit fee computation in aggregator
4e5193a2 is described below

commit 4e5193a21fd6084e773e00ed8f638f193a525bab
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jul 9 12:14:20 2022 +0200

    -fix full refund deposit fee computation in aggregator
---
 doc/prebuilt                                |  2 +-
 src/exchangedb/plugin_exchangedb_postgres.c | 32 ++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/doc/prebuilt b/doc/prebuilt
index 1ed97b23..b988d98d 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit 1ed97b23f19c80fa84b21a5eb0c686d5491e8ec6
+Subproject commit b988d98d4856758484eb23c27bfdc9e602d4235a
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index ee120a01..277e3bc4 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1778,10 +1778,31 @@ prepare_statements (struct PostgresClosure *pg)
       "    FROM refunds"
       "   WHERE coin_pub IN (SELECT coin_pub FROM dep)"
       "     AND deposit_serial_id IN (SELECT deposit_serial_id FROM dep))"
-      " ,fees AS (" /* find deposit fees for non-refunded deposits */
-      // FIXME: this is wrong, the deposit fee is waived IF the
-      // refunds were for 100% of the deposit value. This logic
-      // ignores this detail :-(.
+      " ,ref_by_coin AS (" /* total up refunds by coin */
+      "  SELECT"
+      "    SUM(refund_val) AS sum_refund_val"
+      "   ,SUM(refund_frac) AS sum_refund_frac"
+      "   ,coin_pub"
+      "   ,deposit_serial_id" /* theoretically, coin could be in multiple 
refunded transactions */
+      "    FROM ref"
+      "   GROUP BY coin_pub, deposit_serial_id)"
+      " ,norm_ref_by_coin AS (" /* normalize */
+      "  SELECT"
+      "    sum_refund_val + sum_refund_frac / 100000000 AS norm_refund_val"
+      "   ,sum_refund_frac % 100000000 AS norm_refund_frac"
+      "   ,coin_pub"
+      "   ,deposit_serial_id" /* theoretically, coin could be in multiple 
refunded transactions */
+      "    FROM ref_by_coin)"
+      " ,fully_refunded_coins AS (" /* find applicable refunds -- NOTE: may do 
a full join on the master, maybe find a left-join way to integrate with query 
above to push it to the shards? */
+      "  SELECT"
+      "    dep.coin_pub"
+      "    FROM norm_ref_by_coin norm"
+      "    JOIN dep"
+      "      ON (norm.coin_pub = dep.coin_pub"
+      "      AND norm.deposit_serial_id = dep.deposit_Serial_id"
+      "      AND norm.norm_refund_val = dep.amount_val"
+      "      AND norm.norm_refund_frac = dep.amount_frac))"
+      " ,fees AS (" /* find deposit fees for not fully refunded deposits */
       "  SELECT"
       "    denom.fee_deposit_val AS fee_val"
       "   ,denom.fee_deposit_frac AS fee_frac"
@@ -1790,7 +1811,8 @@ prepare_statements (struct PostgresClosure *pg)
       "    JOIN known_coins kc" /* NOTE: may do a full join on the master, 
maybe find a left-join way to integrate with query above to push it to the 
shards? */
       "      USING (coin_pub)"
       "    JOIN denominations denom"
-      "      USING (denominations_serial))"
+      "      USING (denominations_serial)"
+      "    WHERE coin_pub NOT IN (SELECT coin_pub FROM fully_refunded_coins))"
       " ,dummy AS (" /* add deposits to aggregation_tracking */
       "    INSERT INTO aggregation_tracking"
       "    (deposit_serial_id"

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]