implement that /track/transaction returns execution time (#4578)

This commit is contained in:
Christian Grothoff 2016-09-26 14:50:49 +02:00
parent 265fc74b65
commit 302a08b701
5 changed files with 43 additions and 23 deletions

View File

@ -1772,6 +1772,11 @@ struct WtidTransactionContext
*/
struct GNUNET_HashCode h_wire;
/**
* Execution time of the wire transfer
*/
struct GNUNET_TIME_Absolute exec_time;
/**
* Head of DLL with details for /wire/deposit response.
*/
@ -1806,6 +1811,7 @@ struct WtidTransactionContext
* @param cls our context for transmission
* @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls)
* @param h_wire hash of wire transfer details of the merchant (should be same for all callbacks with the same @e cls)
* @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls)
* @param h_contract which contract was this payment about
* @param transaction_id merchant's transaction ID for the payment
* @param coin_pub which public key was this payment about
@ -1816,6 +1822,7 @@ static void
handle_transaction_data (void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute exec_time,
const struct GNUNET_HashCode *h_contract,
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
@ -1832,6 +1839,7 @@ handle_transaction_data (void *cls,
{
ctx->merchant_pub = *merchant_pub;
ctx->h_wire = *h_wire;
ctx->exec_time = exec_time;
ctx->is_valid = GNUNET_YES;
if (GNUNET_OK !=
TALER_amount_subtract (&ctx->total,
@ -1939,6 +1947,7 @@ TMH_DB_execute_track_transfer (struct MHD_Connection *connection,
&ctx.total,
&ctx.merchant_pub,
&ctx.h_wire,
ctx.exec_time,
ctx.wdd_head);
cleanup:
while (NULL != (wdd = ctx.wdd_head))

View File

@ -1181,15 +1181,17 @@ TMH_RESPONSE_reply_track_transaction (struct MHD_Connection *connection,
* @param total total amount that was transferred
* @param merchant_pub public key of the merchant
* @param h_wire destination account
* @param exec_time execution time of the wire transfer
* @param wdd_head linked list with details about the combined deposits
* @return MHD result code
*/
int
TMH_RESPONSE_reply_track_transfer_details (struct MHD_Connection *connection,
const struct TALER_Amount *total,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
const struct TMH_TrackTransferDetail *wdd_head)
const struct TALER_Amount *total,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute exec_time,
const struct TMH_TrackTransferDetail *wdd_head)
{
const struct TMH_TrackTransferDetail *wdd_pos;
json_t *deposits;
@ -1235,10 +1237,11 @@ TMH_RESPONSE_reply_track_transfer_details (struct MHD_Connection *connection,
&sig);
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:o, s:o, s:o, s:o, s:o, s:o}",
"{s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"total", TALER_JSON_from_amount (total),
"merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub),
"H_wire", GNUNET_JSON_from_data_auto (h_wire),
"execution_time", GNUNET_JSON_from_time_abs (exec_time),
"deposits", deposits,
"exchange_sig", GNUNET_JSON_from_data_auto (&sig),
"exchange_pub", GNUNET_JSON_from_data_auto (&pub));

View File

@ -326,13 +326,13 @@ TMH_RESPONSE_reply_transfer_pending (struct MHD_Connection *connection,
*/
int
TMH_RESPONSE_reply_track_transaction (struct MHD_Connection *connection,
const struct GNUNET_HashCode *h_contract,
const struct GNUNET_HashCode *h_wire,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_contribution,
uint64_t transaction_id,
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute exec_time);
const struct GNUNET_HashCode *h_contract,
const struct GNUNET_HashCode *h_wire,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_contribution,
uint64_t transaction_id,
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute exec_time);
/**
@ -386,15 +386,17 @@ struct TMH_TrackTransferDetail
* @param total total amount that was transferred
* @param merchant_pub public key of the merchant
* @param h_wire destination account
* @param exec_time execution time of the wire transfer
* @param wdd_head linked list with details about the combined deposits
* @return MHD result code
*/
int
TMH_RESPONSE_reply_track_transfer_details (struct MHD_Connection *connection,
const struct TALER_Amount *total,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
const struct TMH_TrackTransferDetail *wdd_head);
const struct TALER_Amount *total,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute exec_time,
const struct TMH_TrackTransferDetail *wdd_head);
/**

View File

@ -3757,8 +3757,8 @@ postgres_lookup_wire_transfer (void *cls,
/* check if the melt record exists and get it */
result = GNUNET_PQ_exec_prepared (session->conn,
"lookup_transactions",
params);
"lookup_transactions",
params);
if (PGRES_TUPLES_OK != PQresultStatus (result))
{
BREAK_DB_ERR (result);
@ -3794,7 +3794,10 @@ postgres_lookup_wire_transfer (void *cls,
TALER_PQ_result_spec_amount ("fee_deposit", &deposit_fee),
GNUNET_PQ_result_spec_end
};
if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, i))
if (GNUNET_OK !=
GNUNET_PQ_extract_result (result,
rs,
i))
{
GNUNET_break (0);
PQclear (result);
@ -3803,6 +3806,7 @@ postgres_lookup_wire_transfer (void *cls,
cb (cb_cls,
&merchant_pub,
&h_wire,
exec_time,
&h_contract,
transaction_id,
&coin_pub,

View File

@ -614,10 +614,10 @@ typedef void
*/
typedef void
(*TALER_EXCHANGEDB_TrackTransactionCallback)(void *cls,
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *coin_contribution,
const struct TALER_Amount *coin_fee,
struct GNUNET_TIME_Absolute execution_time);
const struct TALER_WireTransferIdentifierRawP *wtid,
const struct TALER_Amount *coin_contribution,
const struct TALER_Amount *coin_fee,
struct GNUNET_TIME_Absolute execution_time);
/**
@ -627,6 +627,7 @@ typedef void
* @param cls closure
* @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls)
* @param h_wire hash of wire transfer details of the merchant (should be same for all callbacks with the same @e cls)
* @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls)
* @param h_contract which contract was this payment about
* @param transaction_id merchant's transaction ID for the payment
* @param coin_pub which public key was this payment about
@ -637,6 +638,7 @@ typedef void
(*TALER_EXCHANGEDB_WireTransferDataCallback)(void *cls,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct GNUNET_HashCode *h_wire,
struct GNUNET_TIME_Absolute exec_time,
const struct GNUNET_HashCode *h_contract,
uint64_t transaction_id,
const struct TALER_CoinSpendPublicKeyP *coin_pub,