diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-06-18 21:47:05 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-06-19 00:17:15 +0200 |
commit | 2ec1b055a0f574e3837f2fbbb38098db4eb65f6f (patch) | |
tree | 8070390b91f43d07f68b7f2d785a3dd68c593658 /src/exchange/taler-exchange-httpd_db.h | |
parent | d2c7ef54a7eb906b40032969b5bc45c180003f4b (diff) | |
download | exchange-2ec1b055a0f574e3837f2fbbb38098db4eb65f6f.tar.gz exchange-2ec1b055a0f574e3837f2fbbb38098db4eb65f6f.tar.bz2 exchange-2ec1b055a0f574e3837f2fbbb38098db4eb65f6f.zip |
refactoring /deposit towards new transaction style (#5010)
Diffstat (limited to 'src/exchange/taler-exchange-httpd_db.h')
-rw-r--r-- | src/exchange/taler-exchange-httpd_db.h | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 55faafa06..6d0b7e35a 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h @@ -24,20 +24,63 @@ #include <microhttpd.h> #include "taler_exchangedb_plugin.h" +/** + * Function implementing a database transaction. Runs the transaction + * logic; IF it returns a non-error code, the transaction logic MUST + * NOT queue a MHD response. IF it returns an hard error, the + * transaction logic MUST queue a MHD response and set @a mhd_ret. IF + * it returns the soft error code, the function MAY be called again to + * retry and MUST not queue a MHD response. + * + * @param cls closure + * @param connection MHD request which triggered the transaction + * @param session database session to use + * @param[out] mhd_ret set to MHD response status for @a connection, + * if transaction failed (!) + * @return transaction status + */ +typedef enum GNUNET_DB_QueryStatus +(*TEH_DB_TransactionCallback)(void *cls, + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret); + /** - * Execute a "/deposit". The validity of the coin and signature - * have already been checked. The database must now check that - * the coin is not (double or over) spent, and execute the - * transaction (record details, generate success or failure response). + * Run a database transaction for @a connection. + * Starts a transaction and calls @a cb. Upon success, + * attempts to commit the transaction. Upon soft failures, + * retries @a cb a few times. Upon hard or persistent soft + * errors, generates an error message for @a connection. + * + * @param connection MHD connection to run @a cb for + * @param[out] set to MHD response code, if transaction failed + * @param cb callback implementing transaction logic + * @param cb_cls closure for @a cb, must be read-only! + * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure + */ +int +TEH_DB_run_transaction (struct MHD_Connection *connection, + int *mhd_ret, + TEH_DB_TransactionCallback cb, + void *cb_cls); + + +/** + * Calculate the total value of all transactions performed. + * Stores @a off plus the cost of all transactions in @a tl + * in @a ret. * - * @param connection the MHD connection to handle - * @param deposit information about the deposit - * @return MHD result code + * @param tl transaction list to process + * @param off offset to use as the starting value + * @param[out] ret where the resulting total is to be stored + * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ +// FIXME: maybe move to another module? int -TEH_DB_execute_deposit (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_Deposit *deposit); +TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl, + const struct TALER_Amount *off, + struct TALER_Amount *ret); /** |