aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
diff options
context:
space:
mode:
authorMarco Boss <bossm8@bfh.ch>2022-05-13 15:28:43 +0200
committerMarco Boss <bossm8@bfh.ch>2022-05-13 15:28:43 +0200
commit42f3f83b7d703d41c89976a90b6b745b0d350353 (patch)
tree2626194bf1c9ddb3cfb0f6006866b008a448e515 /src/exchangedb/plugin_exchangedb_postgres.c
parentd6c161a72e56a15602f581ba0cb7b7a1610f2529 (diff)
add recoup_by_reserve as sql function
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 4175678a..e6b86813 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -2064,41 +2064,17 @@ prepare_statements (struct PostgresClosure *pg)
" ON (recoup_by_reserve.reserve_out_serial_id = reserves_out.reserve_out_serial_id)"
" WHERE reserves.reserve_pub=$1);",
*/
- "WITH res AS MATERIALIZED ( "
- " SELECT * "
- " FROM reserves "
- " WHERE reserve_pub = $1 "
- "), "
- "coin_pub AS MATERIALIZED ( "
- " SELECT coin_pub "
- " FROM recoup_by_reserve "
- " JOIN (reserves_out "
- " JOIN ( "
- " SELECT * "
- " FROM reserves_out_by_reserve "
- " WHERE reserves_out_by_reserve.reserve_uuid = ( "
- " SELECT reserve_uuid FROM res "
- " ) "
- " ) reserves_out_by_reserve "
- " ON (reserves_out_by_reserve.h_blind_ev = reserves_out.h_blind_ev)) "
- " ON (recoup_by_reserve.reserve_out_serial_id = reserves_out.reserve_out_serial_id) "
- ") "
- "SELECT recoup.coin_pub "
- " ,recoup.coin_sig "
- " ,recoup.coin_blind "
- " ,recoup.amount_val "
- " ,recoup.amount_frac "
- " ,recoup.recoup_timestamp "
+ "SELECT robr.coin_pub "
+ " ,robr.coin_sig "
+ " ,robr.coin_blind "
+ " ,robr.amount_val "
+ " ,robr.amount_frac "
+ " ,robr.recoup_timestamp "
" ,denominations.denom_pub_hash "
- " ,known_coins.denom_sig "
+ " ,robr.denom_sig "
"FROM denominations "
- " JOIN (known_coins "
- " JOIN recoup "
- " ON (recoup.coin_pub = known_coins.coin_pub)) "
- " ON (known_coins.denominations_serial = denominations.denominations_serial) "
- "WHERE recoup.coin_pub = ( "
- " SELECT coin_pub FROM coin_pub "
- "); ",
+ " JOIN exchange_do_recoup_by_reserve($1) robr"
+ " USING (denominations_serial);",
1),
/* Used in #postgres_get_coin_transactions() to obtain recoup transactions
affecting old coins of refreshed coins */