aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-17 08:50:28 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-17 08:50:42 +0200
commit802649c2703cb1b9991316073ca0b9e20cebe16f (patch)
tree590eb7af77af7350c8e6101dd962260359dcd32a /src/exchangedb/plugin_exchangedb_postgres.c
parentf089bbe5366553c15758200febd6c77a941272f2 (diff)
downloadexchange-802649c2703cb1b9991316073ca0b9e20cebe16f.tar.xz
-add DB logic for purse expiration
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index ab282f4ff..2c113cf19 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -904,6 +904,14 @@ prepare_statements (struct PostgresClosure *pg)
" FROM exchange_do_purse_deposit"
" ($1,$2,$3,$4,$5,$6,$7,$8);",
8),
+ /* used in #postgres_expire_purse() */
+ GNUNET_PQ_make_prepare (
+ "call_expire_purse",
+ "SELECT "
+ " out_found AS found"
+ " FROM exchange_do_expire_purse"
+ " ($1,$2);",
+ 2),
/* Used in #postgres_do_melt() to melt a coin. */
GNUNET_PQ_make_prepare (
"call_melt",
@@ -13337,7 +13345,7 @@ postgres_select_contract_by_purse (void *cls,
* @param[out] in_conflict set to true if @a econtract
* conflicts with an existing contract;
* in this case, the return value will be
- * #GNUNET_DB_STATUS_SUCCESS_ONE despite the failure
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT despite the failure
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
@@ -13568,8 +13576,30 @@ postgres_expire_purse (
struct GNUNET_TIME_Absolute start_time,
struct GNUNET_TIME_Absolute end_time)
{
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_absolute_time (&start_time),
+ GNUNET_PQ_query_param_absolute_time (&end_time),
+ GNUNET_PQ_query_param_end
+ };
+ bool found = false;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_bool ("found",
+ &found),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "call_expire_purse",
+ params,
+ rs);
+ if (qs < 0)
+ return qs;
+ GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
+ return found
+ ? GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
+ : GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}