[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: -modify DB logic to return open/
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: -modify DB logic to return open/close requests in reserve history |
Date: |
Sat, 15 Oct 2022 19:12:40 +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 2a852aae -modify DB logic to return open/close requests in reserve
history
2a852aae is described below
commit 2a852aaeba8e58a41dce1e9fe8bf171a1dfd7271
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Oct 15 19:12:37 2022 +0200
-modify DB logic to return open/close requests in reserve history
---
src/exchangedb/pg_get_coin_transactions.c | 2 +-
src/exchangedb/pg_get_reserve_history.c | 171 ++++++++++++++++++++++++++++++
src/exchangedb/test_exchangedb.c | 10 ++
3 files changed, 182 insertions(+), 1 deletion(-)
diff --git a/src/exchangedb/pg_get_coin_transactions.c
b/src/exchangedb/pg_get_coin_transactions.c
index b6b892e5..27bd513f 100644
--- a/src/exchangedb/pg_get_coin_transactions.c
+++ b/src/exchangedb/pg_get_coin_transactions.c
@@ -809,7 +809,7 @@ TEH_PG_get_coin_transactions (
" USING (denominations_serial)"
" WHERE ref.coin_pub=$1;");
PREPARE (pg,
- "get_purse_refund_by_coin",
+ "get_purse_refund_by_coin_pub",
"SELECT"
" pr.purse_pub"
",pd.amount_with_fee_val"
diff --git a/src/exchangedb/pg_get_reserve_history.c
b/src/exchangedb/pg_get_reserve_history.c
index c3ccab1f..60a95e89 100644
--- a/src/exchangedb/pg_get_reserve_history.c
+++ b/src/exchangedb/pg_get_reserve_history.c
@@ -480,6 +480,121 @@ add_history_requests (void *cls,
}
+/**
+ * Add paid for history requests to result set for
+ * #postgres_get_reserve_history.
+ *
+ * @param cls a `struct ReserveHistoryContext *`
+ * @param result SQL result
+ * @param num_results number of rows in @a result
+ */
+static void
+add_open_requests (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct ReserveHistoryContext *rhc = cls;
+ struct PostgresClosure *pg = rhc->pg;
+
+ while (0 < num_results)
+ {
+ struct TALER_EXCHANGEDB_OpenRequest *orq;
+ struct TALER_EXCHANGEDB_ReserveHistory *tail;
+
+ orq = GNUNET_new (struct TALER_EXCHANGEDB_OpenRequest);
+ {
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ TALER_PQ_RESULT_SPEC_AMOUNT ("open_fee",
+ &orq->open_fee),
+ GNUNET_PQ_result_spec_timestamp ("request_timestamp",
+ &orq->request_timestamp),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ &orq->reserve_expiration),
+ GNUNET_PQ_result_spec_uint32 ("requested_purse_limit",
+ &orq->purse_limit),
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
+ &orq->reserve_sig),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ --num_results))
+ {
+ GNUNET_break (0);
+ GNUNET_free (orq);
+ rhc->status = GNUNET_SYSERR;
+ return;
+ }
+ }
+ GNUNET_assert (0 <=
+ TALER_amount_add (&rhc->balance_out,
+ &rhc->balance_out,
+ &orq->open_fee));
+ orq->reserve_pub = *rhc->reserve_pub;
+ tail = append_rh (rhc);
+ tail->type = TALER_EXCHANGEDB_RO_OPEN_REQUEST;
+ tail->details.open_request = orq;
+ }
+}
+
+
+/**
+ * Add paid for history requests to result set for
+ * #postgres_get_reserve_history.
+ *
+ * @param cls a `struct ReserveHistoryContext *`
+ * @param result SQL result
+ * @param num_results number of rows in @a result
+ */
+static void
+add_close_requests (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct ReserveHistoryContext *rhc = cls;
+
+ while (0 < num_results)
+ {
+ struct TALER_EXCHANGEDB_CloseRequest *crq;
+ struct TALER_EXCHANGEDB_ReserveHistory *tail;
+
+ crq = GNUNET_new (struct TALER_EXCHANGEDB_CloseRequest);
+ {
+ char *payto_uri;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_timestamp ("close_timestamp",
+ &crq->request_timestamp),
+ GNUNET_PQ_result_spec_string ("payto_uri",
+ &payto_uri),
+ GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
+ &crq->reserve_sig),
+ GNUNET_PQ_result_spec_end
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ --num_results))
+ {
+ GNUNET_break (0);
+ GNUNET_free (crq);
+ rhc->status = GNUNET_SYSERR;
+ return;
+ }
+ TALER_payto_hash (payto_uri,
+ &crq->target_account_h_payto);
+ GNUNET_free (payto_uri);
+ }
+ crq->reserve_pub = *rhc->reserve_pub;
+ tail = append_rh (rhc);
+ tail->type = TALER_EXCHANGEDB_RO_CLOSE_REQUEST;
+ tail->details.close_request = crq;
+ }
+}
+
+
enum GNUNET_DB_QueryStatus
TEH_PG_get_reserve_history (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
@@ -517,6 +632,12 @@ TEH_PG_get_reserve_history (void *cls,
/** #TALER_EXCHANGEDB_RO_HISTORY_REQUEST */
{ "history_by_reserve",
&add_history_requests },
+ /** #TALER_EXCHANGEDB_RO_OPEN_REQUEST */
+ { "open_request_by_reserve",
+ &add_open_requests },
+ /** #TALER_EXCHANGEDB_RO_CLOSE_REQUEST */
+ { "close_request_by_reserve",
+ &add_close_requests },
/* List terminator */
{ NULL,
NULL }
@@ -697,6 +818,27 @@ TEH_PG_get_reserve_history (void *cls,
" FROM history_requests"
" WHERE reserve_pub=$1;");
+ PREPARE (pg,
+ "open_request_by_reserve",
+ "SELECT"
+ " reserve_payment_val"
+ ",reserve_payment_frac"
+ ",request_timestamp"
+ ",expiration_date"
+ ",requested_purse_limit"
+ ",reserve_sig"
+ " FROM reserves_open_requests"
+ " WHERE reserve_pub=$1;");
+
+ PREPARE (pg,
+ "close_request_by_reserve",
+ "SELECT"
+ " close_timestamp"
+ ",payto_uri"
+ ",reserve_sig"
+ " FROM close_requests"
+ " WHERE reserve_pub=$1;");
+
rhc.reserve_pub = reserve_pub;
rhc.rh = NULL;
rhc.rh_tail = NULL;
@@ -779,6 +921,12 @@ TEH_PG_get_reserve_status (void *cls,
/** #TALER_EXCHANGEDB_RO_HISTORY_REQUEST */
{ "history_by_reserve_truncated",
&add_history_requests },
+ /** #TALER_EXCHANGEDB_RO_OPEN_REQUEST */
+ { "open_request_by_reserve_truncated",
+ &add_open_requests },
+ /** #TALER_EXCHANGEDB_RO_CLOSE_REQUEST */
+ { "close_request_by_reserve_truncated",
+ &add_close_requests },
/* List terminator */
{ NULL,
NULL }
@@ -972,6 +1120,29 @@ TEH_PG_get_reserve_status (void *cls,
" WHERE reserve_pub=$1"
" AND request_timestamp>=$2;");
+ PREPARE (pg,
+ "open_request_by_reserve_truncated",
+ "SELECT"
+ " reserve_payment_val"
+ ",reserve_payment_frac"
+ ",request_timestamp"
+ ",expiration_date"
+ ",requested_purse_limit"
+ ",reserve_sig"
+ " FROM reserves_open_requests"
+ " WHERE reserve_pub=$1"
+ " AND request_timestamp>=$2;");
+
+ PREPARE (pg,
+ "close_request_by_reserve_truncated",
+ "SELECT"
+ " close_timestamp"
+ ",payto_uri"
+ ",reserve_sig"
+ " FROM close_requests"
+ " WHERE reserve_pub=$1"
+ " AND close_timestamp>=$2;");
+
timelimit = GNUNET_TIME_absolute_subtract (
GNUNET_TIME_absolute_get (),
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_WEEKS,
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 1d14c7d5..d19f91a4 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1912,6 +1912,16 @@ run (void *cls)
/* FIXME: not yet tested */
break;
}
+ case TALER_EXCHANGEDB_RO_OPEN_REQUEST:
+ {
+ /* FIXME: not yet tested */
+ break;
+ }
+ case TALER_EXCHANGEDB_RO_CLOSE_REQUEST:
+ {
+ /* FIXME: not yet tested */
+ break;
+ }
}
}
GNUNET_assert (4 == cnt);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: -modify DB logic to return open/close requests in reserve history,
gnunet <=