aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-09-26 14:50:49 +0200
committerChristian Grothoff <christian@grothoff.org>2016-09-26 14:50:49 +0200
commit302a08b7018b18a18939d49e132ca8db78a2be9a (patch)
tree44ab352820b814d87663ccd33cb8c5727bc44b1d /src
parent265fc74b656910dda559f410aa140c57de261cc9 (diff)
implement that /track/transaction returns execution time (#4578)
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_db.c9
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c13
-rw-r--r--src/exchange/taler-exchange-httpd_responses.h24
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c10
-rw-r--r--src/include/taler_exchangedb_plugin.h10
5 files changed, 43 insertions, 23 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index f1c69b7a9..d265f6f47 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -1773,6 +1773,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.
*/
struct TMH_TrackTransferDetail *wdd_head;
@@ -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))
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 5be8d1773..47a709a67 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -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));
diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h
index 82317d89a..0f99b7491 100644
--- a/src/exchange/taler-exchange-httpd_responses.h
+++ b/src/exchange/taler-exchange-httpd_responses.h
@@ -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);
/**
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index bd8670eb7..a90ff849d 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -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,
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 32910e960..63327fcd4 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -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,