[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 23/152: modify TALER_EXCHANGE_deposits_get() API to avo
From: |
gnunet |
Subject: |
[taler-exchange] 23/152: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies |
Date: |
Sun, 05 Jul 2020 20:46:19 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 275ff5e8aab1a3630adf22d232eab209ada4f01f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 3 20:12:18 2020 +0200
modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need
for deep copies
---
src/include/taler_exchange_service.h | 16 +++++++--------
src/lib/exchange_api_deposits_get.c | 31 +++++++++++-------------------
src/testing/testing_api_cmd_deposits_get.c | 5 ++---
3 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/src/include/taler_exchange_service.h
b/src/include/taler_exchange_service.h
index 32012304..f94b8253 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1691,22 +1691,22 @@ struct TALER_EXCHANGE_DepositData
{
/**
- * exchange key used to sign, NULL if exchange did not
+ * exchange key used to sign, all zeros if exchange did not
* yet execute the transaction
*/
- const struct TALER_ExchangePublicKeyP *exchange_pub;
+ struct TALER_ExchangePublicKeyP exchange_pub;
/**
- * signature from the exchange over the deposit data, NULL if exchange did
not
+ * signature from the exchange over the deposit data, all zeros if exchange
did not
* yet execute the transaction
*/
- const struct TALER_ExchangeSignatureP *exchange_sig;
+ struct TALER_ExchangeSignatureP exchange_sig;
/**
- * wire transfer identifier used by the exchange, NULL if exchange did not
+ * wire transfer identifier used by the exchange, all zeros if exchange did
not
* yet execute the transaction
*/
- const struct TALER_WireTransferIdentifierRawP *wtid;
+ struct TALER_WireTransferIdentifierRawP wtid;
/**
* actual or planned execution time for the wire transfer
@@ -1714,10 +1714,10 @@ struct TALER_EXCHANGE_DepositData
struct GNUNET_TIME_Absolute execution_time;
/**
- * contribution to the total amount by this coin, NULL if exchange did not
+ * contribution to the total amount by this coin, all zeros if exchange did
not
* yet execute the transaction
*/
- const struct TALER_Amount *coin_contribution;
+ struct TALER_Amount coin_contribution;
};
diff --git a/src/lib/exchange_api_deposits_get.c
b/src/lib/exchange_api_deposits_get.c
index 6a2ad5c3..004a24d4 100644
--- a/src/lib/exchange_api_deposits_get.c
+++ b/src/lib/exchange_api_deposits_get.c
@@ -146,16 +146,13 @@ handle_deposit_wtid_finished (void *cls,
break;
case MHD_HTTP_OK:
{
- struct GNUNET_TIME_Absolute execution_time;
- struct TALER_Amount coin_contribution;
- struct TALER_ExchangePublicKeyP exchange_pub;
- struct TALER_ExchangeSignatureP exchange_sig;
+ struct TALER_EXCHANGE_DepositData dd;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid),
- GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time),
- TALER_JSON_spec_amount ("coin_contribution", &coin_contribution),
- GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig),
- GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
+ GNUNET_JSON_spec_absolute_time ("execution_time", &dd.execution_time),
+ TALER_JSON_spec_amount ("coin_contribution", &dd.coin_contribution),
+ GNUNET_JSON_spec_fixed_auto ("exchange_sig", &dd.exchange_sig),
+ GNUNET_JSON_spec_fixed_auto ("exchange_pub", &dd.exchange_pub),
GNUNET_JSON_spec_end ()
};
@@ -169,14 +166,15 @@ handle_deposit_wtid_finished (void *cls,
hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
break;
}
- dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (execution_time);
+ dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (
+ dd.execution_time);
TALER_amount_hton (&dwh->depconf.coin_contribution,
- &coin_contribution);
+ &dd.coin_contribution);
if (GNUNET_OK !=
verify_deposit_wtid_signature_ok (dwh,
j,
- &exchange_pub,
- &exchange_sig))
+ &dd.exchange_pub,
+ &dd.exchange_sig))
{
GNUNET_break_op (0);
hr.http_status = 0;
@@ -184,14 +182,7 @@ handle_deposit_wtid_finished (void *cls,
}
else
{
- struct TALER_EXCHANGE_DepositData dd = {
- .exchange_pub = &exchange_pub,
- .exchange_sig = &exchange_sig,
- .wtid = &dwh->depconf.wtid,
- .execution_time = execution_time,
- .coin_contribution = &coin_contribution
- };
-
+ dd.wtid = dwh->depconf.wtid;
dwh->cb (dwh->cb_cls,
&hr,
&dd);
diff --git a/src/testing/testing_api_cmd_deposits_get.c
b/src/testing/testing_api_cmd_deposits_get.c
index 6f014011..33987e16 100644
--- a/src/testing/testing_api_cmd_deposits_get.c
+++ b/src/testing/testing_api_cmd_deposits_get.c
@@ -111,8 +111,7 @@ deposit_wtid_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- GNUNET_assert (NULL != dd->wtid);
- tts->wtid = *dd->wtid;
+ tts->wtid = dd->wtid;
if (NULL != tts->bank_transfer_reference)
{
const struct TALER_TESTING_Command *bank_transfer_cmd;
@@ -140,7 +139,7 @@ deposit_wtid_cb (void *cls,
}
/* Compare that expected and gotten subjects match. */
- if (0 != GNUNET_memcmp (dd->wtid,
+ if (0 != GNUNET_memcmp (&dd->wtid,
wtid_want))
{
GNUNET_break (0);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 11/152: combine sections, (continued)
- [taler-exchange] 11/152: combine sections, gnunet, 2020/07/05
- [taler-exchange] 12/152: return fee as well, gnunet, 2020/07/05
- [taler-exchange] 13/152: towards changing timestamp in deposit confirmation (tests failing), gnunet, 2020/07/05
- [taler-exchange] 18/152: implement #6181, gnunet, 2020/07/05
- [taler-exchange] 15/152: v8 bump, gnunet, 2020/07/05
- [taler-exchange] 14/152: sleep to ensure aggregator has work, gnunet, 2020/07/05
- [taler-exchange] 17/152: ign, gnunet, 2020/07/05
- [taler-exchange] 16/152: fix status code, gnunet, 2020/07/05
- [taler-exchange] 21/152: update exchange API to return struct instead of lots of individual args for TALER_EXCHANGE_transfers_get() -- simplifies merchant later, gnunet, 2020/07/05
- [taler-exchange] 19/152: void basedb due to signature format change, gnunet, 2020/07/05
- [taler-exchange] 23/152: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies,
gnunet <=
- [taler-exchange] 25/152: return fee as well, gnunet, 2020/07/05
- [taler-exchange] 20/152: make tests skip until we have a wallet to regen the DB, gnunet, 2020/07/05
- [taler-exchange] 22/152: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later), gnunet, 2020/07/05
- [taler-exchange] 24/152: combine sections, gnunet, 2020/07/05
- [taler-exchange] 27/152: sleep to ensure aggregator has work, gnunet, 2020/07/05
- [taler-exchange] 28/152: update, gnunet, 2020/07/05
- [taler-exchange] 40/152: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies, gnunet, 2020/07/05
- [taler-exchange] 35/152: implement #6181, gnunet, 2020/07/05
- [taler-exchange] 37/152: make tests skip until we have a wallet to regen the DB, gnunet, 2020/07/05
- [taler-exchange] 38/152: update exchange API to return struct instead of lots of individual args for TALER_EXCHANGE_transfers_get() -- simplifies merchant later, gnunet, 2020/07/05