[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: -implement purses get db sketch
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: -implement purses get db sketch |
Date: |
Tue, 26 Apr 2022 13:24:53 +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 efb8c803 -implement purses get db sketch
efb8c803 is described below
commit efb8c8037b0d9e4d0407e62156b0021f790ad974
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Apr 26 13:24:44 2022 +0200
-implement purses get db sketch
---
contrib/gana | 2 +-
src/exchange/taler-exchange-httpd_purses_get.c | 8 ++-
src/exchangedb/plugin_exchangedb_postgres.c | 70 ++++++++++++++++++++++++++
src/include/taler_exchangedb_plugin.h | 25 +++++++++
4 files changed, 99 insertions(+), 6 deletions(-)
diff --git a/contrib/gana b/contrib/gana
index fbd5974f..0172bed4 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit fbd5974fba30cab15ef1b7454a5a609286c71508
+Subproject commit 0172bed41a8fdfc4ef2511e311441120a3d2572d
diff --git a/src/exchange/taler-exchange-httpd_purses_get.c
b/src/exchange/taler-exchange-httpd_purses_get.c
index dd904d79..32527288 100644
--- a/src/exchange/taler-exchange-httpd_purses_get.c
+++ b/src/exchange/taler-exchange-httpd_purses_get.c
@@ -295,7 +295,6 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
}
} /* end first-time initialization */
-#if FIXME
{
enum GNUNET_DB_QueryStatus qs;
@@ -324,21 +323,20 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_NOT_FOUND,
- TALER_EC_EXCHANGE_PURSE_UNKNOWN,
+
TALER_EC_EXCHANGE_GENERIC_PURSE_UNKNOWN,
NULL);
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break; /* handled below */
}
}
- if (GNUNET_TIME_absolute_is_past (gc->purse_expiration))
+ if (GNUNET_TIME_absolute_is_past (gc->purse_expiration.abs_time))
{
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_GONE,
- TALER_EC_EXCHANGE_PURSE_EXPIRED,
+ TALER_EC_EXCHANGE_GENERIC_PURSE_EXPIRED,
GNUNET_TIME_timestamp2s (
gc->purse_expiration));
}
-#endif
// FIXME: compare amount to deposited amount;
// if below, set 'deposit_timestamp' to zero!
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index ebdcae40..af4cbc78 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -13351,6 +13351,74 @@ postgres_insert_purse_request (
}
+/**
+ * Function called to obtain information about a purse.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param purse_pub public key of the new purse
+ * @param[out] purse_expiration set to time when the purse will expire
+ * @param[out] amount set to target amount (with fees) to be put into the purse
+ * @param[out] deposited set to actual amount put into the purse so far
+ * @param[out] h_contract_terms set to hash of the contract for the purse
+ * @param[out] merge_timestamp set to time when the purse was merged, or NEVER
if not
+ * @param[out] deposit_timestamp set to time when the deposited amount reached
the target amount, or NEVER if not
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_select_purse (
+ void *cls,
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ struct GNUNET_TIME_Timestamp *purse_expiration,
+ struct TALER_Amount *amount,
+ struct TALER_Amount *deposited,
+ struct TALER_PrivateContractHashP *h_contract_terms,
+ struct GNUNET_TIME_Timestamp *merge_timestamp,
+ struct GNUNET_TIME_Timestamp *deposit_timestamp)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (purse_pub),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_timestamp ("purse_expiration",
+ purse_expiration),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
+ amount),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("balance",
+ deposited),
+ GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
+ h_contract_terms),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("merge_timestamp",
+ merge_timestamp),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("deposit_timestamp",
+ deposit_timestamp),
+ NULL),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ *merge_timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
+ *deposit_timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "select_purse_request",
+ params,
+ rs);
+ if ( (qs > 0) &&
+ (0 <
+ TALER_amount_cmp (amount,
+ deposited)) )
+ {
+ /* not yet enough */
+ *deposit_timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
+ }
+ return qs;
+}
+
+
/**
* Function called to return meta data about a purse by the
* merge capability key.
@@ -14021,6 +14089,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &postgres_insert_purse_request;
plugin->select_purse_request
= &postgres_select_purse_request;
+ plugin->select_purse
+ = &postgres_select_purse;
plugin->select_purse_by_merge_pub
= &postgres_select_purse_by_merge_pub;
plugin->do_purse_deposit
diff --git a/src/include/taler_exchangedb_plugin.h
b/src/include/taler_exchangedb_plugin.h
index cf265c10..27b0d1b0 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -4546,6 +4546,31 @@ struct TALER_EXCHANGEDB_Plugin
bool *in_conflict);
+ /**
+ * Function called to obtain information about a purse.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param purse_pub public key of the new purse
+ * @param[out] purse_expiration set to time when the purse will expire
+ * @param[out] amount set to target amount (with fees) to be put into the
purse
+ * @param[out] deposited set to actual amount put into the purse so far
+ * @param[out] h_contract_terms set to hash of the contract for the purse
+ * @param[out] merge_timestamp set to time when the purse was merged, or
NEVER if not
+ * @param[out] deposit_timestamp set to time when the deposited amount
reached the target amount, or NEVER if not
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_purse)(
+ void *cls,
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ struct GNUNET_TIME_Timestamp *purse_expiration,
+ struct TALER_Amount *amount,
+ struct TALER_Amount *deposited,
+ struct TALER_PrivateContractHashP *h_contract_terms,
+ struct GNUNET_TIME_Timestamp *merge_timestamp,
+ struct GNUNET_TIME_Timestamp *deposit_timestamp);
+
+
/**
* Function called to reutrn meta data about a purse by the
* purse public key.
--
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: -implement purses get db sketch,
gnunet <=