[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated (6e3197d27 -> 1fa056392)
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated (6e3197d27 -> 1fa056392) |
Date: |
Tue, 12 Nov 2024 00:03:28 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository exchange.
from 6e3197d27 fix test: init auditor and exchange DB before running test
new a269dd820 limit reserve expiration query to reserves that actually had
an incoming wire transfer, as purely purse-filled reserves cannot be closed
(fixes #9209)
new 1fa056392 fix very bad amount subtraction that created free money
under certain circumstances, plus some SQL code cleanup
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/exchangedb/exchange_do_purse_merge.sql | 32 +++++++++++++++---------------
src/exchangedb/pg_get_expired_reserves.c | 31 ++++++++++++++---------------
2 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/src/exchangedb/exchange_do_purse_merge.sql
b/src/exchangedb/exchange_do_purse_merge.sql
index 946fd7e97..25b752fcd 100644
--- a/src/exchangedb/exchange_do_purse_merge.sql
+++ b/src/exchangedb/exchange_do_purse_merge.sql
@@ -39,7 +39,7 @@ DECLARE
DECLARE
rval RECORD;
DECLARE
- reserve RECORD;
+ reserve_bal RECORD;
DECLARE
balance taler_amount;
BEGIN
@@ -64,7 +64,7 @@ ELSE
partner_serial_id
INTO
my_partner_serial_id
- FROM exchange.partners
+ FROM partners
WHERE partner_base_url=in_partner_url
AND start_date <= in_merge_timestamp
AND end_date > in_merge_timestamp;
@@ -204,28 +204,28 @@ ELSE
my_amount.val = my_amount.val + my_amount.frac / 100000000;
my_amount.frac = my_amount.frac % 100000000;
- SELECT *
- INTO reserve
- FROM exchange.reserves
- WHERE reserve_pub=in_reserve_pub;
+ SELECT current_balance
+ INTO reserve_bal
+ FROM reserves
+ WHERE reserve_pub=in_reserve_pub;
- balance = reserve.current_balance;
- balance.frac=balance.frac+my_amount.frac
- - CASE
- WHEN balance.frac + my_amount.frac >= 100000000
- THEN 100000000
- ELSE 0
- END;
+ balance = reserve_bal.current_balance;
balance.val=balance.val+my_amount.val
+ CASE
WHEN balance.frac + my_amount.frac >= 100000000
THEN 1
ELSE 0
END;
+ balance.frac=balance.frac+my_amount.frac
+ - CASE
+ WHEN balance.frac + my_amount.frac >= 100000000
+ THEN 100000000
+ ELSE 0
+ END;
- UPDATE exchange.reserves
- SET current_balance=balance
- WHERE reserve_pub=in_reserve_pub;
+ UPDATE reserves
+ SET current_balance=balance
+ WHERE reserve_pub=in_reserve_pub;
END IF;
diff --git a/src/exchangedb/pg_get_expired_reserves.c
b/src/exchangedb/pg_get_expired_reserves.c
index df069d4d4..2bb4da5fc 100644
--- a/src/exchangedb/pg_get_expired_reserves.c
+++ b/src/exchangedb/pg_get_expired_reserves.c
@@ -135,27 +135,26 @@ TEH_PG_get_expired_reserves (
PREPARE (pg,
"get_expired_reserves",
"WITH ed AS MATERIALIZED ( "
- " SELECT * "
- " FROM reserves "
+ " SELECT expiration_date"
+ " ,wire_source_h_payto"
+ " ,current_balance"
+ " ,r.reserve_pub"
+ " FROM reserves r"
+ " JOIN reserves_in"
+ " USING (reserve_pub)"
" WHERE expiration_date <= $1 "
" AND ((current_balance).val != 0 OR (current_balance).frac != 0)
"
" ORDER BY expiration_date ASC "
" LIMIT 1 "
") "
- "SELECT "
- " ed.expiration_date "
- " ,payto_uri AS account_details "
- " ,ed.reserve_pub "
- " ,current_balance "
- "FROM ( "
- " SELECT "
- " * "
- " FROM reserves_in "
- " WHERE reserve_pub = ( "
- " SELECT reserve_pub FROM ed) "
- " ) ri "
- "JOIN wire_targets wt ON (ri.wire_source_h_payto =
wt.wire_target_h_payto) "
- "JOIN ed ON (ri.reserve_pub = ed.reserve_pub);");
+ "SELECT"
+ " wt.payto_uri AS account_details"
+ " ,ed.expiration_date"
+ " ,ed.reserve_pub"
+ " ,ed.current_balance"
+ " FROM wire_targets wt"
+ " JOIN ed"
+ " ON (ed.wire_source_h_payto=wt.wire_target_h_payto);");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"get_expired_reserves",
params,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] branch master updated (6e3197d27 -> 1fa056392),
gnunet <=