remove dead globals

This commit is contained in:
Christian Grothoff 2020-01-17 18:01:56 +01:00
parent 67bfd94009
commit 8313dbd569
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 57 additions and 75 deletions

View File

@ -74,16 +74,6 @@ struct ExchangeHttpRequestClosure
}; };
/**
* Which currency is used by this exchange?
*/
char *TEH_exchange_currency_string;
/**
* Should we return "Connection: close" in each response?
*/
int TEH_exchange_connection_close;
/** /**
* Base directory of the exchange (global) * Base directory of the exchange (global)
*/ */
@ -102,7 +92,7 @@ struct GNUNET_CONFIGURATION_Handle *cfg;
/** /**
* How long is caching /keys allowed at most? * How long is caching /keys allowed at most?
*/ */
struct GNUNET_TIME_Relative max_keys_caching; struct GNUNET_TIME_Relative TEH_max_keys_caching;
/** /**
* Master public key (according to the * Master public key (according to the
@ -481,8 +471,6 @@ handle_mhd_request (void *cls,
static int static int
exchange_serve_process_config () exchange_serve_process_config ()
{ {
char *TEH_master_public_key_str;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg, GNUNET_CONFIGURATION_get_value_number (cfg,
"exchange", "exchange",
@ -495,7 +483,7 @@ exchange_serve_process_config ()
GNUNET_CONFIGURATION_get_value_time (cfg, GNUNET_CONFIGURATION_get_value_time (cfg,
"exchange", "exchange",
"MAX_KEYS_CACHING", "MAX_KEYS_CACHING",
&max_keys_caching)) &TEH_max_keys_caching))
{ {
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"exchange", "exchange",
@ -525,30 +513,39 @@ exchange_serve_process_config ()
"REVOCATION_DIR"); "REVOCATION_DIR");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
{
char *currency_string;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"taler", "taler",
"CURRENCY", "CURRENCY",
&TEH_exchange_currency_string)) &currency_string))
{ {
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler", "taler",
"currency"); "CURRENCY");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (strlen (TEH_exchange_currency_string) >= TALER_CURRENCY_LEN) if (strlen (currency_string) >= TALER_CURRENCY_LEN)
{ {
fprintf (stderr, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"Currency `%s' longer than the allowed limit of %u characters.", "taler",
TEH_exchange_currency_string, "CURRENCY",
(unsigned int) TALER_CURRENCY_LEN); "Value is too long");
GNUNET_free (currency_string);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_free (currency_string);
}
{
char *master_public_key_str;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange", "exchange",
"MASTER_PUBLIC_KEY", "MASTER_PUBLIC_KEY",
&TEH_master_public_key_str)) &master_public_key_str))
{ {
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange", "exchange",
@ -556,18 +553,19 @@ exchange_serve_process_config ()
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (TEH_master_public_key_str, GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str,
strlen ( strlen (
TEH_master_public_key_str), master_public_key_str),
&TEH_master_public_key. &TEH_master_public_key.
eddsa_pub)) eddsa_pub))
{ {
fprintf (stderr, fprintf (stderr,
"Invalid master public key given in exchange configuration."); "Invalid master public key given in exchange configuration.");
GNUNET_free (TEH_master_public_key_str); GNUNET_free (master_public_key_str);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_free (TEH_master_public_key_str); GNUNET_free (master_public_key_str);
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Launching exchange with public key `%s'...\n", "Launching exchange with public key `%s'...\n",
GNUNET_p2s (&TEH_master_public_key.eddsa_pub)); GNUNET_p2s (&TEH_master_public_key.eddsa_pub));
@ -784,11 +782,12 @@ main (int argc,
char *cfgfile = NULL; char *cfgfile = NULL;
char *loglev = NULL; char *loglev = NULL;
char *logfile = NULL; char *logfile = NULL;
int connection_close;
const struct GNUNET_GETOPT_CommandLineOption options[] = { const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_flag ('C', GNUNET_GETOPT_option_flag ('C',
"connection-close", "connection-close",
"force HTTP connections to be closed after each request", "force HTTP connections to be closed after each request",
&TEH_exchange_connection_close), &connection_close),
GNUNET_GETOPT_option_cfgfile (&cfgfile), GNUNET_GETOPT_option_cfgfile (&cfgfile),
GNUNET_GETOPT_option_flag ('i', GNUNET_GETOPT_option_flag ('i',
"init-db", "init-db",
@ -825,7 +824,7 @@ main (int argc,
argc, argv)) argc, argv))
return 1; return 1;
go = TALER_MHD_GO_NONE; go = TALER_MHD_GO_NONE;
if (TEH_exchange_connection_close) if (connection_close)
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
TALER_MHD_setup (go); TALER_MHD_setup (go);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V. Copyright (C) 2014, 2015, 2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software terms of the GNU Affero General Public License as published by the Free Software
@ -19,8 +19,6 @@
* @author Florian Dold * @author Florian Dold
* @author Benedikt Mueller * @author Benedikt Mueller
* @author Christian Grothoff * @author Christian Grothoff
*
* FIXME: Consider which of these need to really be globals...
*/ */
#ifndef TALER_EXCHANGE_HTTPD_H #ifndef TALER_EXCHANGE_HTTPD_H
#define TALER_EXCHANGE_HTTPD_H #define TALER_EXCHANGE_HTTPD_H
@ -28,20 +26,10 @@
#include <microhttpd.h> #include <microhttpd.h>
/**
* Which currency is used by this exchange?
*/
extern char *TEH_exchange_currency_string;
/**
* Should we return "Connection: close" in each response?
*/
extern int TEH_exchange_connection_close;
/** /**
* How long is caching /keys allowed at most? * How long is caching /keys allowed at most?
*/ */
extern struct GNUNET_TIME_Relative max_keys_caching; extern struct GNUNET_TIME_Relative TEH_max_keys_caching;
/** /**
* The exchange's configuration. * The exchange's configuration.
@ -64,11 +52,6 @@ extern char *TEH_revocation_directory;
*/ */
extern struct TALER_MasterPublicKeyP TEH_master_public_key; extern struct TALER_MasterPublicKeyP TEH_master_public_key;
/**
* Private key of the exchange we use to sign messages.
*/
extern struct GNUNET_CRYPTO_EddsaPrivateKey TEH_exchange_private_signing_key;
/** /**
* Our DB plugin. * Our DB plugin.
*/ */

View File

@ -1258,7 +1258,7 @@ setup_general_response_headers (const struct TEH_KS_StateHandle *key_state,
{ {
struct GNUNET_TIME_Absolute m; struct GNUNET_TIME_Absolute m;
m = GNUNET_TIME_relative_to_absolute (max_keys_caching); m = GNUNET_TIME_relative_to_absolute (TEH_max_keys_caching);
m = GNUNET_TIME_absolute_min (m, m = GNUNET_TIME_absolute_min (m,
key_state->next_reload); key_state->next_reload);
get_date_string (m, get_date_string (m,