style fixes
This commit is contained in:
parent
af61713619
commit
9f885f9ad9
@ -30,6 +30,12 @@
|
|||||||
/**
|
/**
|
||||||
* How often should we retry a transaction before giving up
|
* How often should we retry a transaction before giving up
|
||||||
* (for transactions resulting in serialization/dead locks only).
|
* (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
|
#define MAX_TRANSACTION_COMMIT_RETRIES 100
|
||||||
|
|
||||||
@ -42,10 +48,10 @@
|
|||||||
* it returns the soft error code, the function MAY be called again to
|
* it returns the soft error code, the function MAY be called again to
|
||||||
* retry and MUST not queue a MHD response.
|
* retry and MUST not queue a MHD response.
|
||||||
*
|
*
|
||||||
* @param cls a `struct DepositContext`
|
* @param cls a `struct TEH_DB_KnowCoinContext`
|
||||||
* @param connection MHD request context
|
* @param connection MHD request context, must not be NULL
|
||||||
* @param session database session and transaction to use
|
* @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
|
* @return transaction status
|
||||||
*/
|
*/
|
||||||
enum GNUNET_DB_QueryStatus
|
enum GNUNET_DB_QueryStatus
|
||||||
@ -57,6 +63,7 @@ TEH_DB_know_coin_transaction (void *cls,
|
|||||||
struct TEH_DB_KnowCoinContext *kcc = cls;
|
struct TEH_DB_KnowCoinContext *kcc = cls;
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
GNUNET_assert (NULL != mhd_ret);
|
||||||
qs = TEH_plugin->ensure_coin_known (TEH_plugin->cls,
|
qs = TEH_plugin->ensure_coin_known (TEH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
kcc->coin);
|
kcc->coin);
|
||||||
@ -80,9 +87,11 @@ TEH_DB_know_coin_transaction (void *cls,
|
|||||||
* retries @a cb a few times. Upon hard or persistent soft
|
* retries @a cb a few times. Upon hard or persistent soft
|
||||||
* errors, generates an error message for @a connection.
|
* 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 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 callback implementing transaction logic
|
||||||
* @param cb_cls closure for @a cb, must be read-only!
|
* @param cb_cls closure for @a cb, must be read-only!
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
* @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;
|
struct TALER_EXCHANGEDB_Session *session;
|
||||||
|
|
||||||
if (NULL != mhd_ret)
|
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)))
|
if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -108,7 +117,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
|
|||||||
"could not establish database session");
|
"could not establish database session");
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES;
|
for (unsigned int retries = 0;
|
||||||
|
retries < MAX_TRANSACTION_COMMIT_RETRIES;
|
||||||
retries++)
|
retries++)
|
||||||
{
|
{
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
@ -50,10 +50,10 @@ struct TEH_DB_KnowCoinContext
|
|||||||
* it returns the soft error code, the function MAY be called again to
|
* it returns the soft error code, the function MAY be called again to
|
||||||
* retry and MUST not queue a MHD response.
|
* retry and MUST not queue a MHD response.
|
||||||
*
|
*
|
||||||
* @param cls a `struct DepositContext`
|
* @param cls a `struct TEH_DB_KnowCoinContext`
|
||||||
* @param connection MHD request context
|
* @param connection MHD request context, must not be NULL
|
||||||
* @param session database session and transaction to use
|
* @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
|
* @return transaction status
|
||||||
*/
|
*/
|
||||||
enum GNUNET_DB_QueryStatus
|
enum GNUNET_DB_QueryStatus
|
||||||
@ -92,9 +92,11 @@ typedef enum GNUNET_DB_QueryStatus
|
|||||||
* retries @a cb a few times. Upon hard or persistent soft
|
* retries @a cb a few times. Upon hard or persistent soft
|
||||||
* errors, generates an error message for @a connection.
|
* 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 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 callback implementing transaction logic
|
||||||
* @param cb_cls closure for @a cb, must be read-only!
|
* @param cb_cls closure for @a cb, must be read-only!
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
* @brief Handle wire transfer tracking-related requests
|
* @brief Handle wire transfer tracking-related requests
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_TRACK_TRANSACTION_H
|
#ifndef TALER_EXCHANGE_HTTPD_DEPOSITS_GET_H
|
||||||
#define TALER_EXCHANGE_HTTPD_TRACK_TRANSACTION_H
|
#define TALER_EXCHANGE_HTTPD_DEPOSITS_GET_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_REFRESH_LINK_H
|
#ifndef TALER_EXCHANGE_HTTPD_LINK_H
|
||||||
#define TALER_EXCHANGE_HTTPD_REFRESH_LINK_H
|
#define TALER_EXCHANGE_HTTPD_LINK_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file taler-exchange-httpd_melt.h
|
* @file taler-exchange-httpd_melt.h
|
||||||
* @brief Handle /refresh/melt requests
|
* @brief Handle /coins/$COIN_PUB/melt requests
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_REFRESH_MELT_H
|
#ifndef TALER_EXCHANGE_HTTPD_MELT_H
|
||||||
#define TALER_EXCHANGE_HTTPD_REFRESH_MELT_H
|
#define TALER_EXCHANGE_HTTPD_MELT_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_REFRESH_REVEAL_H
|
#ifndef TALER_EXCHANGE_HTTPD_REFRESHES_REVEAL_H
|
||||||
#define TALER_EXCHANGE_HTTPD_REFRESH_REVEAL_H
|
#define TALER_EXCHANGE_HTTPD_REFRESHES_REVEAL_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_RESERVE_STATUS_H
|
#ifndef TALER_EXCHANGE_HTTPD_RESERVES_GET_H
|
||||||
#define TALER_EXCHANGE_HTTPD_RESERVE_STATUS_H
|
#define TALER_EXCHANGE_HTTPD_RESERVES_GET_H
|
||||||
|
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include "taler-exchange-httpd.h"
|
#include "taler-exchange-httpd.h"
|
||||||
|
@ -216,11 +216,6 @@ struct WtidTransactionContext
|
|||||||
*/
|
*/
|
||||||
struct TALER_MerchantPublicKeyP merchant_pub;
|
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
|
* Hash of the wire details of the merchant (identical for all
|
||||||
* deposits), only valid if @e is_valid is #GNUNET_YES.
|
* deposits), only valid if @e is_valid is #GNUNET_YES.
|
||||||
@ -238,15 +233,20 @@ struct WtidTransactionContext
|
|||||||
struct GNUNET_TIME_Absolute exec_time;
|
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;
|
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;
|
struct AggregatedDepositDetail *wdd_tail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which method was used to wire the funds?
|
||||||
|
*/
|
||||||
|
char *wire_method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON array with details about the individual deposits.
|
* JSON array with details about the individual deposits.
|
||||||
*/
|
*/
|
||||||
@ -294,8 +294,6 @@ handle_deposit_data (void *cls,
|
|||||||
const struct TALER_Amount *deposit_fee)
|
const struct TALER_Amount *deposit_fee)
|
||||||
{
|
{
|
||||||
struct WtidTransactionContext *ctx = cls;
|
struct WtidTransactionContext *ctx = cls;
|
||||||
struct TALER_Amount delta;
|
|
||||||
struct AggregatedDepositDetail *wdd;
|
|
||||||
char *wire_method;
|
char *wire_method;
|
||||||
|
|
||||||
(void) rowid;
|
(void) rowid;
|
||||||
@ -310,10 +308,11 @@ handle_deposit_data (void *cls,
|
|||||||
}
|
}
|
||||||
if (GNUNET_NO == ctx->is_valid)
|
if (GNUNET_NO == ctx->is_valid)
|
||||||
{
|
{
|
||||||
|
/* First one we encounter, setup general information in 'ctx' */
|
||||||
ctx->merchant_pub = *merchant_pub;
|
ctx->merchant_pub = *merchant_pub;
|
||||||
ctx->h_wire = *h_wire;
|
ctx->h_wire = *h_wire;
|
||||||
ctx->exec_time = exec_time;
|
ctx->exec_time = exec_time;
|
||||||
ctx->wire_method = wire_method;
|
ctx->wire_method = wire_method; /* captures the reference */
|
||||||
ctx->is_valid = GNUNET_YES;
|
ctx->is_valid = GNUNET_YES;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_amount_subtract (&ctx->total,
|
TALER_amount_subtract (&ctx->total,
|
||||||
@ -327,6 +326,10 @@ handle_deposit_data (void *cls,
|
|||||||
}
|
}
|
||||||
else
|
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,
|
if ( (0 != GNUNET_memcmp (&ctx->merchant_pub,
|
||||||
merchant_pub)) ||
|
merchant_pub)) ||
|
||||||
(0 != strcmp (wire_method,
|
(0 != strcmp (wire_method,
|
||||||
@ -359,14 +362,19 @@ handle_deposit_data (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wdd = GNUNET_new (struct AggregatedDepositDetail);
|
|
||||||
wdd->deposit_value = *deposit_value;
|
{
|
||||||
wdd->deposit_fee = *deposit_fee;
|
struct AggregatedDepositDetail *wdd;
|
||||||
wdd->h_contract_terms = *h_contract_terms;
|
|
||||||
wdd->coin_pub = *coin_pub;
|
wdd = GNUNET_new (struct AggregatedDepositDetail);
|
||||||
GNUNET_CONTAINER_DLL_insert (ctx->wdd_head,
|
wdd->deposit_value = *deposit_value;
|
||||||
ctx->wdd_tail,
|
wdd->deposit_fee = *deposit_fee;
|
||||||
wdd);
|
wdd->h_contract_terms = *h_contract_terms;
|
||||||
|
wdd->coin_pub = *coin_pub;
|
||||||
|
GNUNET_CONTAINER_DLL_insert (ctx->wdd_head,
|
||||||
|
ctx->wdd_tail,
|
||||||
|
wdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
* @brief Handle wire transfer tracking-related requests
|
* @brief Handle wire transfer tracking-related requests
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_TRACK_TRANSFER_H
|
#ifndef TALER_EXCHANGE_HTTPD_TRANSFERS_GET_H
|
||||||
#define TALER_EXCHANGE_HTTPD_TRACK_TRANSFER_H
|
#define TALER_EXCHANGE_HTTPD_TRANSFERS_GET_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_EXCHANGE_HTTPD_RESERVE_WITHDRAW_H
|
#ifndef TALER_EXCHANGE_HTTPD_WITHDRAW_H
|
||||||
#define TALER_EXCHANGE_HTTPD_RESERVE_WITHDRAW_H
|
#define TALER_EXCHANGE_HTTPD_WITHDRAW_H
|
||||||
|
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include "taler-exchange-httpd.h"
|
#include "taler-exchange-httpd.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user