summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-20 13:20:45 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-20 13:20:45 +0100
commit427417b8352c2036dc6f5c0ca6bd20c0b7edd225 (patch)
tree54b96b474e9af87586e12763333b04257849798a /src/exchange
parentdee45bf02284716d5dea18e94193d74e64f7e5bf (diff)
downloadexchange-427417b8352c2036dc6f5c0ca6bd20c0b7edd225.tar.gz
exchange-427417b8352c2036dc6f5c0ca6bd20c0b7edd225.tar.bz2
exchange-427417b8352c2036dc6f5c0ca6bd20c0b7edd225.zip
towards support for new reserve history/status APIs
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c64
-rw-r--r--src/exchange/taler-exchange-httpd_keys.h80
2 files changed, 106 insertions, 38 deletions
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 1012a8c03..658e5a347 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -280,31 +280,6 @@ struct SigningKey
};
-/**
- * Set of global fees (and options) for a time range.
- */
-struct GlobalFee
-{
- /**
- * Kept in a DLL.
- */
- struct GlobalFee *next;
-
- /**
- * Kept in a DLL.
- */
- struct GlobalFee *prev;
-
- struct GNUNET_TIME_Timestamp start_date;
- struct GNUNET_TIME_Timestamp end_date;
- struct GNUNET_TIME_Relative purse_timeout;
- struct GNUNET_TIME_Relative kyc_timeout;
- struct GNUNET_TIME_Relative history_expiration;
- struct TALER_MasterSignatureP master_sig;
- struct TALER_GlobalFeeSet fees;
- uint32_t purse_account_limit;
-};
-
struct TEH_KeyStateHandle
{
@@ -324,12 +299,12 @@ struct TEH_KeyStateHandle
/**
* Head of DLL of our global fees.
*/
- struct GlobalFee *gf_head;
+ struct TEH_GlobalFee *gf_head;
/**
* Tail of DLL of our global fees.
*/
- struct GlobalFee *gf_tail;
+ struct TEH_GlobalFee *gf_tail;
/**
* json array with the auditors of this exchange. Contains exactly
@@ -1215,7 +1190,7 @@ static void
destroy_key_state (struct TEH_KeyStateHandle *ksh,
bool free_helper)
{
- struct GlobalFee *gf;
+ struct TEH_GlobalFee *gf;
clear_response_cache (ksh);
while (NULL != (gf = ksh->gf_head))
@@ -2282,9 +2257,9 @@ global_fee_info_cb (
const struct TALER_MasterSignatureP *master_sig)
{
struct TEH_KeyStateHandle *ksh = cls;
- struct GlobalFee *gf;
+ struct TEH_GlobalFee *gf;
- gf = GNUNET_new (struct GlobalFee);
+ gf = GNUNET_new (struct TEH_GlobalFee);
gf->start_date = start_date;
gf->end_date = end_date;
gf->fees = *fees;
@@ -2517,11 +2492,32 @@ TEH_keys_get_state (void)
}
+const struct TEH_GlobalFee *
+TEH_keys_global_fee_by_time (
+ struct TEH_KeyStateHandle *ksh,
+ struct GNUNET_TIME_Timestamp ts)
+{
+ for (const struct TEH_GlobalFee *gf = ksh->gf_head;
+ NULL != gf;
+ gf = gf->next)
+ {
+ if (GNUNET_TIME_timestamp_cmp (ts,
+ >=,
+ gf->start_date) &&
+ GNUNET_TIME_timestamp_cmp (ts,
+ <,
+ gf->end_date))
+ return gf;
+ }
+ return NULL;
+}
+
+
struct TEH_DenominationKey *
-TEH_keys_denomination_by_hash (const struct
- TALER_DenominationHashP *h_denom_pub,
- struct MHD_Connection *conn,
- MHD_RESULT *mret)
+TEH_keys_denomination_by_hash (
+ const struct TALER_DenominationHashP *h_denom_pub,
+ struct MHD_Connection *conn,
+ MHD_RESULT *mret)
{
struct TEH_KeyStateHandle *ksh;
diff --git a/src/exchange/taler-exchange-httpd_keys.h b/src/exchange/taler-exchange-httpd_keys.h
index ee9412a65..732ee032d 100644
--- a/src/exchange/taler-exchange-httpd_keys.h
+++ b/src/exchange/taler-exchange-httpd_keys.h
@@ -83,6 +83,64 @@ struct TEH_DenominationKey
/**
+ * Set of global fees (and options) for a time range.
+ */
+struct TEH_GlobalFee
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct TEH_GlobalFee *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct TEH_GlobalFee *prev;
+
+ /**
+ * Beginning of the validity period (inclusive).
+ */
+ struct GNUNET_TIME_Timestamp start_date;
+
+ /**
+ * End of the validity period (exclusive).
+ */
+ struct GNUNET_TIME_Timestamp end_date;
+
+ /**
+ * How long do unmerged purses stay around at most?
+ */
+ struct GNUNET_TIME_Relative purse_timeout;
+
+ /**
+ * How long do we keep accounts without KYC?
+ */
+ struct GNUNET_TIME_Relative kyc_timeout;
+
+ /**
+ * What is the longest history we return?
+ */
+ struct GNUNET_TIME_Relative history_expiration;
+
+ /**
+ * Signature affirming these details.
+ */
+ struct TALER_MasterSignatureP master_sig;
+
+ /**
+ * Fee structure for operations that do not depend
+ * on a denomination or wire method.
+ */
+ struct TALER_GlobalFeeSet fees;
+
+ /**
+ * Number of free purses per account.
+ */
+ uint32_t purse_account_limit;
+};
+
+
+/**
* Snapshot of the (coin and signing) keys (including private keys) of
* the exchange. There can be multiple instances of this struct, as it is
* reference counted and only destroyed once the last user is done
@@ -130,6 +188,20 @@ TEH_keys_update_states (void);
/**
+ * Look up global fee structure by @a ts.
+ *
+ * @param ksh key state state to look in
+ * @param ts timestamp to lookup global fees at
+ * @return the global fee details, or
+ * NULL if none are configured for @a ts
+ */
+const struct TEH_GlobalFee *
+TEH_keys_global_fee_by_time (
+ struct TEH_KeyStateHandle *ksh,
+ struct GNUNET_TIME_Timestamp ts);
+
+
+/**
* Look up the issue for a denom public key. Note that the result
* must only be used in this thread and only until another key or
* key state is resolved.
@@ -141,10 +213,10 @@ TEH_keys_update_states (void);
* or NULL if @a h_denom_pub could not be found
*/
struct TEH_DenominationKey *
-TEH_keys_denomination_by_hash (const struct
- TALER_DenominationHashP *h_denom_pub,
- struct MHD_Connection *conn,
- MHD_RESULT *mret);
+TEH_keys_denomination_by_hash (
+ const struct TALER_DenominationHashP *h_denom_pub,
+ struct MHD_Connection *conn,
+ MHD_RESULT *mret);
/**