summaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-31 12:37:39 +0200
committerChristian Grothoff <grothoff@gnunet.org>2022-03-31 12:37:39 +0200
commit747ae5ef094731650911838a51e49db778b18ab6 (patch)
tree967b8e61f5bd746a21de645f989d65aa323b6aa4 /src/exchangedb
parenteadee56dcf9d2fed8b8e94d271db31e3c3832cfa (diff)
downloadexchange-747ae5ef094731650911838a51e49db778b18ab6.tar.gz
exchange-747ae5ef094731650911838a51e49db778b18ab6.tar.bz2
exchange-747ae5ef094731650911838a51e49db778b18ab6.zip
privatize more signature structs, simplify code
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c143
-rw-r--r--src/exchangedb/test_exchangedb.c58
2 files changed, 84 insertions, 117 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index a157c64f2..ec26a6dd0 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3550,27 +3550,26 @@ static enum GNUNET_DB_QueryStatus
postgres_insert_denomination_info (
void *cls,
const struct TALER_DenominationPublicKey *denom_pub,
- const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue)
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
{
struct PostgresClosure *pg = cls;
struct TALER_DenominationHashP denom_hash;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (&issue->properties.denom_hash),
+ GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash),
TALER_PQ_query_param_denom_pub (denom_pub),
GNUNET_PQ_query_param_auto_from_type (&issue->signature),
- GNUNET_PQ_query_param_timestamp_nbo (&issue->properties.start),
- GNUNET_PQ_query_param_timestamp_nbo (&issue->properties.expire_withdraw),
- GNUNET_PQ_query_param_timestamp_nbo (&issue->properties.expire_deposit),
- GNUNET_PQ_query_param_timestamp_nbo (&issue->properties.expire_legal),
- TALER_PQ_query_param_amount_nbo (&issue->properties.value),
- TALER_PQ_query_param_amount_nbo (&issue->properties.fees.withdraw),
- TALER_PQ_query_param_amount_nbo (&issue->properties.fees.deposit),
- TALER_PQ_query_param_amount_nbo (&issue->properties.fees.refresh),
- TALER_PQ_query_param_amount_nbo (&issue->properties.fees.refund),
+ GNUNET_PQ_query_param_timestamp (&issue->start),
+ GNUNET_PQ_query_param_timestamp (&issue->expire_withdraw),
+ GNUNET_PQ_query_param_timestamp (&issue->expire_deposit),
+ GNUNET_PQ_query_param_timestamp (&issue->expire_legal),
+ TALER_PQ_query_param_amount (&issue->value),
+ TALER_PQ_query_param_amount (&issue->fees.withdraw),
+ TALER_PQ_query_param_amount (&issue->fees.deposit),
+ TALER_PQ_query_param_amount (&issue->fees.refresh),
+ TALER_PQ_query_param_amount (&issue->fees.refund),
GNUNET_PQ_query_param_uint32 (&denom_pub->age_mask.bits),
GNUNET_PQ_query_param_end
};
- struct TALER_DenomFeeSet fees;
GNUNET_assert (denom_pub->age_mask.bits ==
issue->age_mask.bits);
@@ -3578,26 +3577,20 @@ postgres_insert_denomination_info (
&denom_hash);
GNUNET_assert (0 ==
GNUNET_memcmp (&denom_hash,
- &issue->properties.denom_hash));
+ &issue->denom_hash));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
- GNUNET_TIME_timestamp_ntoh (
- issue->properties.start).abs_time));
+ issue->start.abs_time));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
- GNUNET_TIME_timestamp_ntoh (
- issue->properties.expire_withdraw).abs_time));
+ issue->expire_withdraw.abs_time));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
- GNUNET_TIME_timestamp_ntoh (
- issue->properties.expire_deposit).abs_time));
+ issue->expire_deposit.abs_time));
GNUNET_assert (! GNUNET_TIME_absolute_is_zero (
- GNUNET_TIME_timestamp_ntoh (
- issue->properties.expire_legal).abs_time));
+ issue->expire_legal.abs_time));
/* check fees match denomination currency */
- TALER_denom_fee_set_ntoh (&fees,
- &issue->properties.fees);
GNUNET_assert (GNUNET_YES ==
TALER_denom_fee_check_currency (
- issue->properties.value.currency,
- &fees));
+ issue->value.currency,
+ &issue->fees));
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"denomination_insert",
params);
@@ -3616,7 +3609,7 @@ static enum GNUNET_DB_QueryStatus
postgres_get_denomination_info (
void *cls,
const struct TALER_DenominationHashP *denom_pub_hash,
- struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue)
+ struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
@@ -3627,43 +3620,36 @@ postgres_get_denomination_info (
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("master_sig",
&issue->signature),
- GNUNET_PQ_result_spec_timestamp_nbo ("valid_from",
- &issue->properties.start),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_withdraw",
- &issue->properties.expire_withdraw),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_deposit",
- &issue->properties.expire_deposit),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_legal",
- &issue->properties.expire_legal),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin",
- &issue->properties.value),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw",
- &issue->properties.fees.withdraw),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit",
- &issue->properties.fees.deposit),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refresh",
- &issue->properties.fees.refresh),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refund",
- &issue->properties.fees.refund),
+ GNUNET_PQ_result_spec_timestamp ("valid_from",
+ &issue->start),
+ GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
+ &issue->expire_withdraw),
+ GNUNET_PQ_result_spec_timestamp ("expire_deposit",
+ &issue->expire_deposit),
+ GNUNET_PQ_result_spec_timestamp ("expire_legal",
+ &issue->expire_legal),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
+ &issue->value),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
+ &issue->fees.withdraw),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
+ &issue->fees.deposit),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
+ &issue->fees.refresh),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
+ &issue->fees.refund),
GNUNET_PQ_result_spec_uint32 ("age_mask",
&issue->age_mask.bits),
GNUNET_PQ_result_spec_end
};
- memset (&issue->properties.master,
- 0,
- sizeof (issue->properties.master));
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"denomination_get",
params,
rs);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
return qs;
- issue->properties.purpose.size
- = htonl (sizeof (struct TALER_DenominationKeyValidityPS));
- issue->properties.purpose.purpose = htonl (
- TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
- issue->properties.denom_hash = *denom_pub_hash;
+ issue->denom_hash = *denom_pub_hash;
return qs;
}
@@ -3708,7 +3694,7 @@ domination_cb_helper (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
- struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
+ struct TALER_EXCHANGEDB_DenominationKeyInformation issue;
struct TALER_DenominationPublicKey denom_pub;
struct TALER_DenominationHashP denom_hash;
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -3716,24 +3702,24 @@ domination_cb_helper (void *cls,
&issue.signature),
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&denom_hash),
- GNUNET_PQ_result_spec_timestamp_nbo ("valid_from",
- &issue.properties.start),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_withdraw",
- &issue.properties.expire_withdraw),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_deposit",
- &issue.properties.expire_deposit),
- GNUNET_PQ_result_spec_timestamp_nbo ("expire_legal",
- &issue.properties.expire_legal),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin",
- &issue.properties.value),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw",
- &issue.properties.fees.withdraw),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit",
- &issue.properties.fees.deposit),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refresh",
- &issue.properties.fees.refresh),
- TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refund",
- &issue.properties.fees.refund),
+ GNUNET_PQ_result_spec_timestamp ("valid_from",
+ &issue.start),
+ GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
+ &issue.expire_withdraw),
+ GNUNET_PQ_result_spec_timestamp ("expire_deposit",
+ &issue.expire_deposit),
+ GNUNET_PQ_result_spec_timestamp ("expire_legal",
+ &issue.expire_legal),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
+ &issue.value),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
+ &issue.fees.withdraw),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
+ &issue.fees.deposit),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
+ &issue.fees.refresh),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
+ &issue.fees.refund),
TALER_PQ_result_spec_denom_pub ("denom_pub",
&denom_pub),
GNUNET_PQ_result_spec_uint32 ("age_mask",
@@ -3741,10 +3727,6 @@ domination_cb_helper (void *cls,
GNUNET_PQ_result_spec_end
};
- memset (&issue.properties.master,
- 0,
- sizeof (issue.properties.master));
-
if (GNUNET_OK !=
GNUNET_PQ_extract_result (result,
rs,
@@ -3756,18 +3738,13 @@ domination_cb_helper (void *cls,
/* Unfortunately we have to carry the age mask in both, the
* TALER_DenominationPublicKey and
- * TALER_EXCHANGEDB_DenominationKeyInformationP at different times.
+ * TALER_EXCHANGEDB_DenominationKeyInformation at different times.
* Here we use _both_ so let's make sure the values are the same. */
denom_pub.age_mask = issue.age_mask;
-
- issue.properties.purpose.size
- = htonl (sizeof (struct TALER_DenominationKeyValidityPS));
- issue.properties.purpose.purpose
- = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
TALER_denom_pub_hash (&denom_pub,
- &issue.properties.denom_hash);
+ &issue.denom_hash);
if (0 !=
- GNUNET_memcmp (&issue.properties.denom_hash,
+ GNUNET_memcmp (&issue.denom_hash,
&denom_hash))
{
GNUNET_break (0);
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 6f941b9dc..4112b3d15 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -275,7 +275,7 @@ create_denom_key_pair (unsigned int size,
{
struct DenomKeyPair *dkp;
struct TALER_EXCHANGEDB_DenominationKey dki;
- struct TALER_EXCHANGEDB_DenominationKeyInformationP issue2;
+ struct TALER_EXCHANGEDB_DenominationKeyInformation issue2;
dkp = GNUNET_new (struct DenomKeyPair);
GNUNET_assert (GNUNET_OK ==
@@ -289,38 +289,28 @@ create_denom_key_pair (unsigned int size,
0,
sizeof (struct TALER_EXCHANGEDB_DenominationKey));
dki.denom_pub = dkp->pub;
- dki.issue.properties.start = GNUNET_TIME_timestamp_hton (now);
- dki.issue.properties.expire_withdraw
- = GNUNET_TIME_timestamp_hton
- (GNUNET_TIME_absolute_to_timestamp
- (GNUNET_TIME_absolute_add (
- now.abs_time,
- GNUNET_TIME_UNIT_HOURS)));
- dki.issue.properties.expire_deposit
- = GNUNET_TIME_timestamp_hton (
- GNUNET_TIME_absolute_to_timestamp
- (GNUNET_TIME_absolute_add
- (now.abs_time,
- GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_HOURS, 2))));
- dki.issue.properties.expire_legal
- = GNUNET_TIME_timestamp_hton (
- GNUNET_TIME_absolute_to_timestamp
- (GNUNET_TIME_absolute_add
- (now.abs_time,
- GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_HOURS, 3))));
- TALER_amount_hton (&dki.issue.properties.value,
- value);
- TALER_denom_fee_set_hton (&dki.issue.properties.fees,
- fees);
+ dki.issue.start = now;
+ dki.issue.expire_withdraw
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (
+ now.abs_time,
+ GNUNET_TIME_UNIT_HOURS));
+ dki.issue.expire_deposit
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (
+ now.abs_time,
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_HOURS, 2)));
+ dki.issue.expire_legal
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (
+ now.abs_time,
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_HOURS, 3)));
+ dki.issue.value = *value;
+ dki.issue.fees = *fees;
TALER_denom_pub_hash (&dkp->pub,
- &dki.issue.properties.denom_hash);
-
- dki.issue.properties.purpose.size
- = htonl (sizeof (struct TALER_DenominationKeyValidityPS));
- dki.issue.properties.purpose.purpose = htonl (
- TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
+ &dki.issue.denom_hash);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_denomination_info (plugin->cls,
&dki.denom_pub,
@@ -334,7 +324,7 @@ create_denom_key_pair (unsigned int size,
plugin->commit (plugin->cls);
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->get_denomination_info (plugin->cls,
- &dki.issue.properties.denom_hash,
+ &dki.issue.denom_hash,
&issue2))
{
GNUNET_break (0);
@@ -764,7 +754,7 @@ test_gc (void)
struct DenomKeyPair *dkp;
struct GNUNET_TIME_Timestamp now;
struct GNUNET_TIME_Timestamp past;
- struct TALER_EXCHANGEDB_DenominationKeyInformationP issue2;
+ struct TALER_EXCHANGEDB_DenominationKeyInformation issue2;
struct TALER_DenominationHashP denom_hash;
now = GNUNET_TIME_timestamp_get ();