From 27c921c7c45f8ea8fed5c945a9e0ae0cfcc1c8e9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 20 Apr 2017 21:38:02 +0200 Subject: finished implementing #4956 in principle, but not yet tested --- src/include/taler_exchange_service.h | 2 +- src/include/taler_exchangedb_lib.h | 1 + src/include/taler_exchangedb_plugin.h | 49 +++++++++++++++++++++++++++++++---- src/include/taler_signatures.h | 9 ++----- 4 files changed, 48 insertions(+), 13 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 15e51bc2a..d1d6f3bda 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -765,7 +765,7 @@ struct TALER_EXCHANGE_ReserveHistory /** * Wire transfer details for the outgoing wire transfer. */ - json_t *transfer_details; + struct TALER_WireTransferIdentifierRawP wtid; /** * Signature of the coin of type diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index 561738c22..e4284c27f 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -23,6 +23,7 @@ #ifndef TALER_EXCHANGEDB_LIB_H #define TALER_EXCHANGEDB_LIB_H + #include "taler_signatures.h" diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 5daa9d2f8..b040077e8 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -100,8 +100,8 @@ struct TALER_EXCHANGEDB_ClosingTransfer * Detailed wire transfer information that uniquely identifies the * wire transfer. */ - json_t *transfer_details; - + struct TALER_WireTransferIdentifierRawP transfer_details; + }; @@ -991,7 +991,25 @@ typedef int const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, const json_t *receiver_account, - const json_t *transfer_details); + const struct TALER_WireTransferIdentifierRawP *transfer_details); + + +/** + * Function called with details about expired reserves. + * + * @param cls closure + * @param reserve_pub public key of the reserve + * @param left amount left in the reserve + * @param account_details information about the reserve's bank account + * @param expiration_date when did the reserve expire + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop + */ +typedef int +(*TALER_EXCHANGEDB_ReserveExpiredCallback)(void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *left, + const json_t *account_details, + struct GNUNET_TIME_Absolute expiration_date); /** @@ -1783,6 +1801,27 @@ struct TALER_EXCHANGEDB_Plugin struct TALER_MasterSignatureP *master_sig); + /** + * Obtain information about expired reserves and their + * remaining balances. + * + * @param cls closure of the plugin + * @param session database connection + * @param now timestamp based on which we decide expiration + * @param rec function to call on expired reserves + * @param rec_cls closure for @a rec + * @return #GNUNET_SYSERR on database error + * #GNUNET_NO if there are no expired non-empty reserves + * #GNUNET_OK on success + */ + int + (*get_expired_reserves)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + struct GNUNET_TIME_Absolute now, + TALER_EXCHANGEDB_ReserveExpiredCallback rec, + void *rec_cls); + + /** * Insert reserve close operation into database. * @@ -1800,10 +1839,10 @@ struct TALER_EXCHANGEDB_Plugin int (*insert_reserve_closed)(void *cls, struct TALER_EXCHANGEDB_Session *session, - struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Absolute execution_date, const json_t *receiver_account, - const json_t *transfer_details, + const struct TALER_WireTransferIdentifierRawP *transfer_details, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee); diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index de9a2f7c7..f46013090 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -46,11 +46,6 @@ */ #define TALER_CNC_KAPPA 3 -/** - * After what time do idle reserves "expire"? We might want to make - * this a configuration option (eventually). - */ -#define TALER_IDLE_RESERVE_EXPIRATION_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 5) /*********************************************/ /* Exchange offline signatures (with master key) */ @@ -1269,9 +1264,9 @@ struct TALER_ReserveCloseConfirmationPS struct GNUNET_HashCode h_wire; /** - * Hash of the transfer details. + * Wire transfer subject. */ - struct GNUNET_HashCode h_transfer; + struct TALER_WireTransferIdentifierRawP wtid; }; -- cgit v1.2.3