[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: [donau] refactor /keys
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: [donau] refactor /keys |
Date: |
Fri, 19 Jan 2024 15:52:41 +0100 |
This is an automated email from the git hooks/post-receive script.
pius-loosli pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new 5b03e45 [donau] refactor /keys
5b03e45 is described below
commit 5b03e45bcd4e7411a4d1efdef4310803ab079edd
Author: Pius Loosli <pius.loosli@students.bfh.ch>
AuthorDate: Fri Jan 19 15:39:09 2024 +0100
[donau] refactor /keys
---
src/donau/donau-httpd_keys.c | 99 ++++++++++++++++++++++----------------------
1 file changed, 49 insertions(+), 50 deletions(-)
diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
index 136ad73..b632b96 100644
--- a/src/donau/donau-httpd_keys.c
+++ b/src/donau/donau-httpd_keys.c
@@ -353,10 +353,10 @@ struct DH_KeyStateHandle
struct HelperState *helpers;
/**
- * Cached reply for a GET /management/keys request. Used so we do not
+ * Cached reply for a GET /keys request. Used so we do not
* re-create the reply every time.
*/
- json_t *management_keys_reply;
+ json_t *keys_reply;
/**
* For which (global) key_generation was this data structure created?
@@ -957,10 +957,10 @@ destroy_key_state (struct DH_KeyStateHandle *ksh,
destroy_key_helpers (ksh->helpers);
GNUNET_free (ksh->helpers);
}
- if (NULL != ksh->management_keys_reply)
+ if (NULL != ksh->keys_reply)
{
- json_decref (ksh->management_keys_reply);
- ksh->management_keys_reply = NULL;
+ json_decref (ksh->keys_reply);
+ ksh->keys_reply = NULL;
}
GNUNET_free (ksh);
}
@@ -1257,7 +1257,7 @@ build_key_state (struct HelperState *hs)
if (GNUNET_OK != setup_key_helpers (ksh->helpers))
{
GNUNET_free (ksh->helpers);
- GNUNET_assert (NULL == ksh->management_keys_reply);
+ GNUNET_assert (NULL == ksh->keys_reply);
GNUNET_free (ksh);
return NULL;
}
@@ -1349,8 +1349,7 @@ DH_keys_get_state ()
"Rebuilding /keys, generation upgrade from %llu to %llu\n",
(unsigned long long ) old_ksh->key_generation,
(unsigned long long ) key_generation);
- ksh = build_key_state (old_ksh->helpers /*,
- management_only*/ );
+ ksh = build_key_state (old_ksh->helpers);
key_state = ksh;
old_ksh->helpers = NULL;
destroy_key_state (old_ksh,
@@ -1363,9 +1362,9 @@ DH_keys_get_state ()
/**
- * Closure for #add_future_donation_unit_cb and #add_future_signkey_cb.
+ * Closure for #add_donation_unit_cb and #add_signkey_cb.
*/
-struct FutureBuilderContext
+struct KeysBuilderContext
{
/**
* Our key state.
@@ -1400,14 +1399,14 @@ add_donation_unitkey_cb (void *cls,
const struct GNUNET_HashCode *h_donation_unit_pub,
void *value)
{
- struct FutureBuilderContext *fbc = cls;
+ struct KeysBuilderContext *kbc = cls;
struct HelperDonationUnit *helper_donation_unit = value;
struct DH_DonationUnitKey *donation_unit_key;
struct DONAUDB_DonationUnitKeyMetaData meta =
{ 0 };
donation_unit_key = GNUNET_CONTAINER_multihashmap_get (
- fbc->ksh->donation_unit_key_map,
+ kbc->ksh->donation_unit_key_map,
h_donation_unit_pub);
if (NULL != donation_unit_key)
return GNUNET_OK; /* skip: this key is already active! */
@@ -1415,7 +1414,7 @@ add_donation_unitkey_cb (void *cls,
// return GNUNET_OK; /* this key already expired! */
GNUNET_assert (
- 0 == json_array_append_new (fbc->donation_units, GNUNET_JSON_PACK (
+ 0 == json_array_append_new (kbc->donation_units, GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("value",
&meta.value),
GNUNET_JSON_pack_uint64 (
"year", meta.validity_year),
@@ -1447,13 +1446,13 @@ add_signkey_cb (void *cls,
const struct GNUNET_PeerIdentity *pid,
void *value)
{
- struct FutureBuilderContext *fbc = cls;
+ struct KeysBuilderContext *kbc = cls;
struct HelperSignkey *hsk = value;
struct SigningKey *sk;
// struct GNUNET_TIME_Timestamp stamp_expire;
// struct GNUNET_TIME_Timestamp legal_end;
- sk = GNUNET_CONTAINER_multipeermap_get (fbc->ksh->signkey_map, pid);
+ sk = GNUNET_CONTAINER_multipeermap_get (kbc->ksh->signkey_map, pid);
if (NULL != sk)
return GNUNET_OK; /* skip: this key is already active */
// if (GNUNET_TIME_relative_is_zero (hsk->validity_duration))
@@ -1465,7 +1464,7 @@ add_signkey_cb (void *cls,
// GNUNET_TIME_absolute_add (stamp_expire.abs_time,
// signkey_legal_duration));
GNUNET_assert (
- 0 == json_array_append_new (fbc->signkeys, GNUNET_JSON_PACK (
+ 0 == json_array_append_new (kbc->signkeys, GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("key",
&hsk->donau_pub),
// GNUNET_JSON_pack_timestamp ("stamp_end",
@@ -1498,43 +1497,43 @@ DH_handler_keys (struct DH_RequestContext *rc,
"no key state");
}
sync_key_helpers (ksh->helpers);
- if (NULL == ksh->management_keys_reply)
+ if (NULL == ksh->keys_reply)
{
- struct FutureBuilderContext fbc =
+ struct KeysBuilderContext kbc =
{ .ksh = ksh, .donation_units = json_array (), .signkeys =
json_array () };
- // if ( (GNUNET_is_zero (&donation_unit_rsa_sm_pub)) &&
- // (GNUNET_is_zero (&donation_unit_cs_sm_pub)) )
- // {
- // /* Either IPC failed, or neither helper had any donation_unit
configured. */
- // return TALER_MHD_reply_with_error (connection,
- // MHD_HTTP_BAD_GATEWAY,
- //
TALER_EC_EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE,
- // NULL);
- // }
- // if (GNUNET_is_zero (&esign_sm_pub))
- // {
- // return TALER_MHD_reply_with_error (connection,
- // MHD_HTTP_BAD_GATEWAY,
- //
TALER_EC_EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE,
- // NULL);
- // }
- GNUNET_assert (NULL != fbc.donation_units);
- GNUNET_assert (NULL != fbc.signkeys);
+ if ( (GNUNET_is_zero (&donation_unit_rsa_sm_pub)) &&
+ (GNUNET_is_zero (&donation_unit_cs_sm_pub)) )
+ {
+ /* Either IPC failed, or neither helper had any donation_unit
configured. */
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_GATEWAY,
+
TALER_EC_EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE,
+ NULL);
+ }
+ if (GNUNET_is_zero (&esign_sm_pub))
+ {
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_GATEWAY,
+
TALER_EC_EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE,
+ NULL);
+ }
+ GNUNET_assert (NULL != kbc.donation_units);
+ GNUNET_assert (NULL != kbc.signkeys);
GNUNET_CONTAINER_multihashmap_iterate (ksh->helpers->donation_unit_keys,
- &add_donation_unitkey_cb, &fbc);
+ &add_donation_unitkey_cb, &kbc);
GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys,
- &add_signkey_cb, &fbc);
+ &add_signkey_cb, &kbc);
reply = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_array_steal ("future_donation_units",
- fbc.donation_units),
- GNUNET_JSON_pack_array_steal ("future_signkeys", fbc.signkeys)
- // GNUNET_JSON_pack_data_auto ("donation_unit_secmod_public_key",
- // &donation_unit_rsa_sm_pub),
- // GNUNET_JSON_pack_data_auto ("donation_unit_secmod_cs_public_key",
- // &donation_unit_cs_sm_pub),
- // GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key",
- // &esign_sm_pub));
+ GNUNET_JSON_pack_array_steal ("donation_units",
+ kbc.donation_units),
+ GNUNET_JSON_pack_array_steal ("signkeys", kbc.signkeys),
+ GNUNET_JSON_pack_data_auto ("donation_unit_secmod_public_key",
+ &donation_unit_rsa_sm_pub),
+ GNUNET_JSON_pack_data_auto ("donation_unit_secmod_cs_public_key",
+ &donation_unit_cs_sm_pub),
+ GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key",
+ &esign_sm_pub)
);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Returning GET /keys response:\n");
if (NULL == reply)
@@ -1543,12 +1542,12 @@ DH_handler_keys (struct DH_RequestContext *rc,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE,
NULL);
- GNUNET_assert (NULL == ksh->management_keys_reply);
- ksh->management_keys_reply = reply;
+ GNUNET_assert (NULL == ksh->keys_reply);
+ ksh->keys_reply = reply;
}
else
{
- reply = ksh->management_keys_reply;
+ reply = ksh->keys_reply;
}
return TALER_MHD_reply_json (connection, reply,
MHD_HTTP_OK);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-donau] branch master updated: [donau] refactor /keys,
gnunet <=