summaryrefslogtreecommitdiff
path: root/src/exchangedb/pg_lookup_records_by_table.c
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-06-26 00:01:31 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-06-26 00:01:31 +0200
commitddedf03a816e5139b235a3ebdf5b600508c5ed5f (patch)
treea65179048fc764ec82ddf645a8982186b0157448 /src/exchangedb/pg_lookup_records_by_table.c
parent70bfe0ed1b9a5dbb6cc487465ef3c3df4cdb0436 (diff)
downloadexchange-ddedf03a816e5139b235a3ebdf5b600508c5ed5f.tar.gz
exchange-ddedf03a816e5139b235a3ebdf5b600508c5ed5f.tar.bz2
exchange-ddedf03a816e5139b235a3ebdf5b600508c5ed5f.zip
[age-withdraw] age-withdraw commit- and reveal-handlers implemented, 12/n
The handlers for the commit- and reveal-phases of the age-withdraw HTTP-endpoints are implemented, yet not active. Still missing: - support for age-withdraw is missing in lib/. - tests
Diffstat (limited to 'src/exchangedb/pg_lookup_records_by_table.c')
-rw-r--r--src/exchangedb/pg_lookup_records_by_table.c118
1 files changed, 21 insertions, 97 deletions
diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c
index 3fcad58c0..7862335ac 100644
--- a/src/exchangedb/pg_lookup_records_by_table.c
+++ b/src/exchangedb/pg_lookup_records_by_table.c
@@ -2762,109 +2762,48 @@ lrbt_cb_table_purse_deletion (void *cls,
/**
- * Function called with age_withdraw_commitments table entries.
+ * Function called with age_withdraw table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lrbt_cb_table_age_withdraw_commitments (void *cls,
- PGresult *result,
- unsigned int num_results)
+lrbt_cb_table_age_withdraw (void *cls,
+ PGresult *result,
+ unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = {
- .table = TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS
+ .table = TALER_EXCHANGEDB_RT_AGE_WITHDRAW
};
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
- "age_withdraw_commitment_id",
+ "age_withdraw_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"h_commitment",
- &td.details.age_withdraw_commitments.h_commitment),
+ &td.details.age_withdraw.h_commitment),
GNUNET_PQ_result_spec_uint16 (
"max_age",
- &td.details.age_withdraw_commitments.max_age),
+ &td.details.age_withdraw.max_age),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
- &td.details.age_withdraw_commitments.amount_with_fee),
+ &td.details.age_withdraw.amount_with_fee),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_pub",
- &td.details.age_withdraw_commitments.reserve_pub),
+ &td.details.age_withdraw.reserve_pub),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_sig",
- &td.details.age_withdraw_commitments.reserve_sig),
+ &td.details.age_withdraw.reserve_sig),
GNUNET_PQ_result_spec_uint32 (
"noreveal_index",
- &td.details.age_withdraw_commitments.noreveal_index),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ctx->error = true;
- return;
- }
- ctx->cb (ctx->cb_cls,
- &td);
- GNUNET_PQ_cleanup_result (rs);
- }
-}
-
-
-/**
- * Function called with age_withdraw_revealed_coins table entries.
- *
- * @param cls closure
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lrbt_cb_table_age_withdraw_revealed_coins (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupRecordsByTableContext *ctx = cls;
- struct TALER_EXCHANGEDB_TableData td = {
- .table = TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS
- };
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 (
- "age_withdraw_revealed_coins_id",
- &td.serial),
- GNUNET_PQ_result_spec_auto_from_type (
- "h_commitment",
- &td.details.age_withdraw_revealed_coins.h_commitment),
- GNUNET_PQ_result_spec_uint32 (
- "freshcoin_index",
- &td.details.age_withdraw_revealed_coins.freshcoin_index),
- GNUNET_PQ_result_spec_uint64 (
- "denominations_serial",
- &td.details.age_withdraw_revealed_coins.denominations_serial),
- /* Note: h_coin_ev is recalculated */
- GNUNET_PQ_result_spec_variable_size (
- "coin_ev",
- (void **) &td.details.age_withdraw_revealed_coins.coin_ev,
- &td.details.age_withdraw_revealed_coins.coin_ev_size),
- TALER_PQ_result_spec_blinded_denom_sig (
- "ev_sig",
- &td.details.refresh_revealed_coins.ev_sig),
- TALER_PQ_result_spec_exchange_withdraw_values (
- "ewv",
- &td.details.refresh_revealed_coins.ewv),
+ &td.details.age_withdraw.noreveal_index),
+ /* TODO[oec]: more fields! */
GNUNET_PQ_result_spec_end
};
@@ -3591,10 +3530,10 @@ TEH_PG_lookup_records_by_table (void *cls,
" ORDER BY purse_deletion_serial_id ASC;");
rh = &lrbt_cb_table_purse_deletion;
break;
- case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
- XPREPARE ("select_above_serial_by_table_age_withdraw_commitments",
+ case TALER_EXCHANGEDB_RT_AGE_WITHDRAW:
+ XPREPARE ("select_above_serial_by_table_age_withdraw",
"SELECT"
- " age_withdraw_commitment_id"
+ " age_withdraw_id"
",h_commitment"
",amount_with_fee_val"
",amount_with_fee_frac"
@@ -3602,26 +3541,11 @@ TEH_PG_lookup_records_by_table (void *cls,
",reserve_pub"
",reserve_sig"
",noreveal_index"
- " FROM age_withdraw_commitments"
- " WHERE age_withdraw_commitment_id > $1"
- " ORDER BY age_withdraw_commitment_id ASC;");
- rh = &lrbt_cb_table_age_withdraw_commitments;
- break;
- case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
- XPREPARE ("select_above_serial_by_table_age_withdraw_revealed_coins",
- "SELECT"
- " age_withdraw_revealed_coins_serial_id"
- ",h_commitment"
- ",freshcoin_index"
- ",denominations_serial"
- ",coin_ev"
- ",h_coin_ev"
- ",ev_sig"
- ",ewv"
- " FROM age_withdraw_revealed_coins"
- " WHERE age_withdraw_revealed_coins_serial_id > $1"
- " ORDER BY age_withdraw_revealed_coins_serial_id ASC;");
- rh = &lrbt_cb_table_age_withdraw_revealed_coins;
+ " FROM age_withdraw"
+ " WHERE age_withdraw_id > $1"
+ " ORDER BY age_withdraw_id ASC;");
+ /* TODO[oec]: MORE FIELDS! */
+ rh = &lrbt_cb_table_age_withdraw;
break;
}
if (NULL == rh)