Call TEH_keys_update_state on extension config change
Fixes #7266 Also better API: - TEH_keys_get_state and - TEH_keys_get_state_for_management_only
This commit is contained in:
parent
bf97de5472
commit
8250d830b6
@ -20,6 +20,7 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_json_lib.h>
|
#include <gnunet/gnunet_json_lib.h>
|
||||||
#include "taler_dbevents.h"
|
#include "taler_dbevents.h"
|
||||||
|
#include "taler-exchange-httpd_keys.h"
|
||||||
#include "taler-exchange-httpd_responses.h"
|
#include "taler-exchange-httpd_responses.h"
|
||||||
#include "taler-exchange-httpd_extensions.h"
|
#include "taler-exchange-httpd_extensions.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
@ -156,6 +157,10 @@ extension_update_event_cb (void *cls,
|
|||||||
TALER_age_mask_to_string (&conf->mask));
|
TALER_age_mask_to_string (&conf->mask));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, call TEH_keys_update_states in order to refresh the cached
|
||||||
|
// values.
|
||||||
|
TEH_keys_update_states ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2623,8 +2623,8 @@ TEH_keys_update_states ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TEH_KeyStateHandle *
|
static struct TEH_KeyStateHandle *
|
||||||
TEH_keys_get_state2 (bool management_only)
|
keys_get_state (bool management_only)
|
||||||
{
|
{
|
||||||
struct TEH_KeyStateHandle *old_ksh;
|
struct TEH_KeyStateHandle *old_ksh;
|
||||||
struct TEH_KeyStateHandle *ksh;
|
struct TEH_KeyStateHandle *ksh;
|
||||||
@ -2659,20 +2659,29 @@ TEH_keys_get_state2 (bool management_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct TEH_KeyStateHandle *
|
||||||
|
TEH_keys_get_state_for_management_only (void)
|
||||||
|
{
|
||||||
|
return keys_get_state (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TEH_KeyStateHandle *
|
struct TEH_KeyStateHandle *
|
||||||
TEH_keys_get_state (void)
|
TEH_keys_get_state (void)
|
||||||
{
|
{
|
||||||
struct TEH_KeyStateHandle *ksh;
|
struct TEH_KeyStateHandle *ksh;
|
||||||
|
|
||||||
ksh = TEH_keys_get_state2 (false);
|
ksh = keys_get_state (false);
|
||||||
if (NULL == ksh)
|
if (NULL == ksh)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (ksh->management_only)
|
if (ksh->management_only)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
finish_keys_response (ksh))
|
finish_keys_response (ksh))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ksh;
|
return ksh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2715,6 +2724,7 @@ TEH_keys_denomination_by_hash (
|
|||||||
NULL);
|
NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TEH_keys_denomination_by_hash2 (ksh,
|
return TEH_keys_denomination_by_hash2 (ksh,
|
||||||
h_denom_pub,
|
h_denom_pub,
|
||||||
conn,
|
conn,
|
||||||
@ -3410,7 +3420,7 @@ TEH_keys_get_timing (const struct TALER_ExchangePublicKeyP *exchange_pub,
|
|||||||
struct HelperSignkey *hsk;
|
struct HelperSignkey *hsk;
|
||||||
struct GNUNET_PeerIdentity pid;
|
struct GNUNET_PeerIdentity pid;
|
||||||
|
|
||||||
ksh = TEH_keys_get_state2 (true);
|
ksh = TEH_keys_get_state_for_management_only ();
|
||||||
if (NULL == ksh)
|
if (NULL == ksh)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -3580,7 +3590,7 @@ TEH_keys_management_get_keys_handler (const struct TEH_RequestHandler *rh,
|
|||||||
json_t *reply;
|
json_t *reply;
|
||||||
|
|
||||||
(void) rh;
|
(void) rh;
|
||||||
ksh = TEH_keys_get_state2 (true);
|
ksh = TEH_keys_get_state_for_management_only ();
|
||||||
if (NULL == ksh)
|
if (NULL == ksh)
|
||||||
{
|
{
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
|
@ -168,18 +168,12 @@ TEH_check_invariants (void);
|
|||||||
struct TEH_KeyStateHandle *
|
struct TEH_KeyStateHandle *
|
||||||
TEH_keys_get_state (void);
|
TEH_keys_get_state (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the key state. Should ONLY be used
|
* Obtain the key state if we should NOT run finish_keys_response() because we
|
||||||
* directly if @a management_only is true. Otherwise use #TEH_keys_get_state().
|
* only need the state for the /management/keys API
|
||||||
*
|
|
||||||
* @param management_only if we should NOT run finish_keys_response()
|
|
||||||
* because we only need the state for the /management/keys API
|
|
||||||
* @return NULL on error
|
|
||||||
*/
|
*/
|
||||||
struct TEH_KeyStateHandle *
|
struct TEH_KeyStateHandle *
|
||||||
TEH_keys_get_state2 (bool management_only);
|
TEH_keys_get_state_for_management_only (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Something changed in the database. Rebuild all key states. This function
|
* Something changed in the database. Rebuild all key states. This function
|
||||||
|
@ -376,8 +376,7 @@ TEH_handler_management_post_keys (
|
|||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Received /management/keys\n");
|
"Received /management/keys\n");
|
||||||
akc.ksh = TEH_keys_get_state2 (true); /* may start its own transaction, thus
|
akc.ksh = TEH_keys_get_state_for_management_only (); /* may start its own transaction, thus must be done here, before we run ours! */
|
||||||
must be done here, before we run ours! */
|
|
||||||
if (NULL == akc.ksh)
|
if (NULL == akc.ksh)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user