summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd_db.c24
-rw-r--r--src/exchange/taler-exchange-httpd_db.h12
-rw-r--r--src/exchange/taler-exchange-httpd_deposits_get.h4
-rw-r--r--src/exchange/taler-exchange-httpd_link.h4
-rw-r--r--src/exchange/taler-exchange-httpd_melt.h6
-rw-r--r--src/exchange/taler-exchange-httpd_refreshes_reveal.h4
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_get.h4
-rw-r--r--src/exchange/taler-exchange-httpd_transfers_get.c44
-rw-r--r--src/exchange/taler-exchange-httpd_transfers_get.h4
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.h4
10 files changed, 65 insertions, 45 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index c0828360f..f98116226 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -30,6 +30,12 @@
/**
* How often should we retry a transaction before giving up
* (for transactions resulting in serialization/dead locks only).
+ *
+ * The current value is likely too high for production. We might want to
+ * benchmark good values once we have a good database setup. The code is
+ * expected to work correctly with any positive value, albeit inefficiently if
+ * we too aggressively force clients to retry the HTTP request merely because
+ * we have database serialization issues.
*/
#define MAX_TRANSACTION_COMMIT_RETRIES 100
@@ -42,10 +48,10 @@
* it returns the soft error code, the function MAY be called again to
* retry and MUST not queue a MHD response.
*
- * @param cls a `struct DepositContext`
- * @param connection MHD request context
+ * @param cls a `struct TEH_DB_KnowCoinContext`
+ * @param connection MHD request context, must not be NULL
* @param session database session and transaction to use
- * @param[out] mhd_ret set to MHD status on error
+ * @param[out] mhd_ret set to MHD status on error, must not be NULL
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
@@ -57,6 +63,7 @@ TEH_DB_know_coin_transaction (void *cls,
struct TEH_DB_KnowCoinContext *kcc = cls;
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_assert (NULL != mhd_ret);
qs = TEH_plugin->ensure_coin_known (TEH_plugin->cls,
session,
kcc->coin);
@@ -80,9 +87,11 @@ TEH_DB_know_coin_transaction (void *cls,
* 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 connection MHD connection to run @a cb for, can be NULL
* @param name name of the transaction (for debugging)
- * @param[out] mhd_ret set to MHD response code, if transaction failed
+ * @param[out] mhd_ret set to MHD response code, if transaction failed;
+ * NULL if we are not running with a @a connection and thus
+ * must not queue MHD replies
* @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
@@ -97,7 +106,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
struct TALER_EXCHANGEDB_Session *session;
if (NULL != mhd_ret)
- *mhd_ret = -1; /* invalid value */
+ *mhd_ret = -1; /* set to invalid value, to help detect bugs */
if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
{
GNUNET_break (0);
@@ -108,7 +117,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
"could not establish database session");
return GNUNET_SYSERR;
}
- for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES;
+ for (unsigned int retries = 0;
+ retries < MAX_TRANSACTION_COMMIT_RETRIES;
retries++)
{
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h
index 5f710aacc..380f00d3e 100644
--- a/src/exchange/taler-exchange-httpd_db.h
+++ b/src/exchange/taler-exchange-httpd_db.h
@@ -50,10 +50,10 @@ struct TEH_DB_KnowCoinContext
* it returns the soft error code, the function MAY be called again to
* retry and MUST not queue a MHD response.
*
- * @param cls a `struct DepositContext`
- * @param connection MHD request context
+ * @param cls a `struct TEH_DB_KnowCoinContext`
+ * @param connection MHD request context, must not be NULL
* @param session database session and transaction to use
- * @param[out] mhd_ret set to MHD status on error
+ * @param[out] mhd_ret set to MHD status on error, must not be NULL
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
@@ -92,9 +92,11 @@ typedef enum GNUNET_DB_QueryStatus
* 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 connection MHD connection to run @a cb for, can be NULL
* @param name name of the transaction (for debugging)
- * @param[out] mhd_ret set to MHD response code, if transaction failed
+ * @param[out] mhd_ret set to MHD response code, if transaction failed;
+ * NULL if we are not running with a @a connection and thus
+ * must not queue MHD replies
* @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
diff --git a/src/exchange/taler-exchange-httpd_deposits_get.h b/src/exchange/taler-exchange-httpd_deposits_get.h
index 64aeedf64..36d072aa8 100644
--- a/src/exchange/taler-exchange-httpd_deposits_get.h
+++ b/src/exchange/taler-exchange-httpd_deposits_get.h
@@ -18,8 +18,8 @@
* @brief Handle wire transfer tracking-related requests
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_TRACK_TRANSACTION_H
-#define TALER_EXCHANGE_HTTPD_TRACK_TRANSACTION_H
+#ifndef TALER_EXCHANGE_HTTPD_DEPOSITS_GET_H
+#define TALER_EXCHANGE_HTTPD_DEPOSITS_GET_H
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
diff --git a/src/exchange/taler-exchange-httpd_link.h b/src/exchange/taler-exchange-httpd_link.h
index 7d4debae3..6fdcf1cff 100644
--- a/src/exchange/taler-exchange-httpd_link.h
+++ b/src/exchange/taler-exchange-httpd_link.h
@@ -20,8 +20,8 @@
* @author Benedikt Mueller
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_REFRESH_LINK_H
-#define TALER_EXCHANGE_HTTPD_REFRESH_LINK_H
+#ifndef TALER_EXCHANGE_HTTPD_LINK_H
+#define TALER_EXCHANGE_HTTPD_LINK_H
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
diff --git a/src/exchange/taler-exchange-httpd_melt.h b/src/exchange/taler-exchange-httpd_melt.h
index 485304390..ad25b4717 100644
--- a/src/exchange/taler-exchange-httpd_melt.h
+++ b/src/exchange/taler-exchange-httpd_melt.h
@@ -15,13 +15,13 @@
*/
/**
* @file taler-exchange-httpd_melt.h
- * @brief Handle /refresh/melt requests
+ * @brief Handle /coins/$COIN_PUB/melt requests
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_REFRESH_MELT_H
-#define TALER_EXCHANGE_HTTPD_REFRESH_MELT_H
+#ifndef TALER_EXCHANGE_HTTPD_MELT_H
+#define TALER_EXCHANGE_HTTPD_MELT_H
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.h b/src/exchange/taler-exchange-httpd_refreshes_reveal.h
index 7fa6eb75f..8778c77f3 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.h
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.h
@@ -20,8 +20,8 @@
* @author Benedikt Mueller
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_REFRESH_REVEAL_H
-#define TALER_EXCHANGE_HTTPD_REFRESH_REVEAL_H
+#ifndef TALER_EXCHANGE_HTTPD_REFRESHES_REVEAL_H
+#define TALER_EXCHANGE_HTTPD_REFRESHES_REVEAL_H
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
diff --git a/src/exchange/taler-exchange-httpd_reserves_get.h b/src/exchange/taler-exchange-httpd_reserves_get.h
index 56ccef5c4..e59d3e031 100644
--- a/src/exchange/taler-exchange-httpd_reserves_get.h
+++ b/src/exchange/taler-exchange-httpd_reserves_get.h
@@ -20,8 +20,8 @@
* @author Benedikt Mueller
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_RESERVE_STATUS_H
-#define TALER_EXCHANGE_HTTPD_RESERVE_STATUS_H
+#ifndef TALER_EXCHANGE_HTTPD_RESERVES_GET_H
+#define TALER_EXCHANGE_HTTPD_RESERVES_GET_H
#include <microhttpd.h>
#include "taler-exchange-httpd.h"
diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c
index 186f9d675..3c5b48994 100644
--- a/src/exchange/taler-exchange-httpd_transfers_get.c
+++ b/src/exchange/taler-exchange-httpd_transfers_get.c
@@ -217,11 +217,6 @@ struct WtidTransactionContext
struct TALER_MerchantPublicKeyP merchant_pub;
/**
- * Which method was used to wire the funds?
- */
- char *wire_method;
-
- /**
* Hash of the wire details of the merchant (identical for all
* deposits), only valid if @e is_valid is #GNUNET_YES.
*/
@@ -238,16 +233,21 @@ struct WtidTransactionContext
struct GNUNET_TIME_Absolute exec_time;
/**
- * Head of DLL with details for /wire/deposit response.
+ * Head of DLL with deposit details for transfers GET response.
*/
struct AggregatedDepositDetail *wdd_head;
/**
- * Head of DLL with details for /wire/deposit response.
+ * Tail of DLL with deposit details for transfers GET response.
*/
struct AggregatedDepositDetail *wdd_tail;
/**
+ * Which method was used to wire the funds?
+ */
+ char *wire_method;
+
+ /**
* JSON array with details about the individual deposits.
*/
json_t *deposits;
@@ -294,8 +294,6 @@ handle_deposit_data (void *cls,
const struct TALER_Amount *deposit_fee)
{
struct WtidTransactionContext *ctx = cls;
- struct TALER_Amount delta;
- struct AggregatedDepositDetail *wdd;
char *wire_method;
(void) rowid;
@@ -310,10 +308,11 @@ handle_deposit_data (void *cls,
}
if (GNUNET_NO == ctx->is_valid)
{
+ /* First one we encounter, setup general information in 'ctx' */
ctx->merchant_pub = *merchant_pub;
ctx->h_wire = *h_wire;
ctx->exec_time = exec_time;
- ctx->wire_method = wire_method;
+ ctx->wire_method = wire_method; /* captures the reference */
ctx->is_valid = GNUNET_YES;
if (GNUNET_OK !=
TALER_amount_subtract (&ctx->total,
@@ -327,6 +326,10 @@ handle_deposit_data (void *cls,
}
else
{
+ struct TALER_Amount delta;
+
+ /* Subsequent data, check general information matches that in 'ctx';
+ (it should, otherwise the deposits should not have been aggregated) */
if ( (0 != GNUNET_memcmp (&ctx->merchant_pub,
merchant_pub)) ||
(0 != strcmp (wire_method,
@@ -359,14 +362,19 @@ handle_deposit_data (void *cls,
return;
}
}
- wdd = GNUNET_new (struct AggregatedDepositDetail);
- wdd->deposit_value = *deposit_value;
- wdd->deposit_fee = *deposit_fee;
- wdd->h_contract_terms = *h_contract_terms;
- wdd->coin_pub = *coin_pub;
- GNUNET_CONTAINER_DLL_insert (ctx->wdd_head,
- ctx->wdd_tail,
- wdd);
+
+ {
+ struct AggregatedDepositDetail *wdd;
+
+ wdd = GNUNET_new (struct AggregatedDepositDetail);
+ wdd->deposit_value = *deposit_value;
+ wdd->deposit_fee = *deposit_fee;
+ wdd->h_contract_terms = *h_contract_terms;
+ wdd->coin_pub = *coin_pub;
+ GNUNET_CONTAINER_DLL_insert (ctx->wdd_head,
+ ctx->wdd_tail,
+ wdd);
+ }
}
diff --git a/src/exchange/taler-exchange-httpd_transfers_get.h b/src/exchange/taler-exchange-httpd_transfers_get.h
index ee5a056c6..37f7dfbd4 100644
--- a/src/exchange/taler-exchange-httpd_transfers_get.h
+++ b/src/exchange/taler-exchange-httpd_transfers_get.h
@@ -18,8 +18,8 @@
* @brief Handle wire transfer tracking-related requests
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_TRACK_TRANSFER_H
-#define TALER_EXCHANGE_HTTPD_TRACK_TRANSFER_H
+#ifndef TALER_EXCHANGE_HTTPD_TRANSFERS_GET_H
+#define TALER_EXCHANGE_HTTPD_TRANSFERS_GET_H
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h>
diff --git a/src/exchange/taler-exchange-httpd_withdraw.h b/src/exchange/taler-exchange-httpd_withdraw.h
index 9c7467664..7fc2fa01f 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.h
+++ b/src/exchange/taler-exchange-httpd_withdraw.h
@@ -20,8 +20,8 @@
* @author Benedikt Mueller
* @author Christian Grothoff
*/
-#ifndef TALER_EXCHANGE_HTTPD_RESERVE_WITHDRAW_H
-#define TALER_EXCHANGE_HTTPD_RESERVE_WITHDRAW_H
+#ifndef TALER_EXCHANGE_HTTPD_WITHDRAW_H
+#define TALER_EXCHANGE_HTTPD_WITHDRAW_H
#include <microhttpd.h>
#include "taler-exchange-httpd.h"