commit 86a7aa73e66bc6088f8f4abe87fff43fc4017cdc
parent 37cc93e1511c0072b6a801d3071932114364392d
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Tue, 27 Oct 2015 09:57:33 +0100
Reverting to the state whithout the mint details being fetched
from the configuration file. I.e. the state when the mint had no
physical address in its JSON
Diffstat:
2 files changed, 27 insertions(+), 161 deletions(-)
diff --git a/src/backend/merchant.c b/src/backend/merchant.c
@@ -48,18 +48,10 @@ TALER_MERCHANT_parse_mints (const struct GNUNET_CONFIGURATION_Handle *cfg,
char *token_nf; /* do no free (nf) */
char *mint_section;
char *mint_hostname;
- char *mint_country;
- char *mint_city;
- char *mint_state;
- char *mint_region;
- char *mint_province;
char *mint_pubkey_enc;
- char *mint_street;
struct MERCHANT_MintInfo *r_mints;
struct MERCHANT_MintInfo mint;
unsigned long long mint_port;
- unsigned long long mint_zip_code;
- unsigned long long mint_street_no;
unsigned int cnt;
int OK;
@@ -68,15 +60,6 @@ TALER_MERCHANT_parse_mints (const struct GNUNET_CONFIGURATION_Handle *cfg,
token_nf = NULL;
mint_section = NULL;
mint_hostname = NULL;
- mint_port = 0;
- mint_country = NULL;
- mint_city = NULL;
- mint_state = NULL;
- mint_region = NULL;
- mint_province = NULL;
- mint_zip_code = 0;
- mint_street = NULL;
- mint_street_no = 0;
mint_pubkey_enc = NULL;
r_mints = NULL;
cnt = 0;
@@ -90,8 +73,6 @@ TALER_MERCHANT_parse_mints (const struct GNUNET_CONFIGURATION_Handle *cfg,
{
GNUNET_assert (0 < GNUNET_asprintf (&mint_section,
"mint-%s", token_nf));
- memset (&mint, 0, sizeof (mint));
-
EXITIF (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
mint_section,
@@ -111,78 +92,14 @@ TALER_MERCHANT_parse_mints (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_CRYPTO_eddsa_public_key_from_string (mint_pubkey_enc,
strlen (mint_pubkey_enc),
&mint.pubkey));
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "COUNTRY",
- &mint_country));
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "CITY",
- &mint_city));
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "STATE",
- &mint_state))
- mint.state = mint_state;
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "REGION",
- &mint_region))
- mint.region = mint_region;
- if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "PROVINCE",
- &mint_province))
- mint.province = mint_province;
-
-
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- mint_section,
- "ZIP_CODE",
- &mint_zip_code));
-
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- mint_section,
- "STREET",
- &mint_street));
-
- EXITIF (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg,
- mint_section,
- "STREET_NUMBER",
- &mint_street_no));
mint.hostname = mint_hostname;
mint.port = (uint16_t) mint_port;
- mint.country = mint_country;
- mint.city = mint_city;
- mint.zip_code = (uint16_t) mint_zip_code;
- mint.street = mint_street;
- mint.street_no = (uint16_t) mint_street_no;
GNUNET_array_append (r_mints, cnt, mint);
- GNUNET_free (mint_hostname);
mint_hostname = NULL;
- GNUNET_free (mint_country);
- mint_country = NULL;
- GNUNET_free (mint_city);
- mint_city = NULL;
- GNUNET_free_non_null (mint_state);
- mint_state = NULL;
- GNUNET_free_non_null (mint_region);
- mint_region = NULL;
- GNUNET_free_non_null (mint_province);
- mint_province = NULL;
- GNUNET_free_non_null (mint_pubkey_enc);
+ GNUNET_free (mint_pubkey_enc);
mint_pubkey_enc = NULL;
- GNUNET_free_non_null (mint_section);
+ GNUNET_free (mint_section);
mint_section = NULL;
-
}
OK = 1;
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -33,7 +33,6 @@
#include "merchant.h"
#include "taler_merchant_lib.h"
#include "taler-mint-httpd_mhd.h"
-#include "taler-merchant-httpd_contract.h"
/**
* Our hostname
@@ -61,7 +60,7 @@ char *keyfile;
static struct TALER_MINT_Context *mctx;
/**
- * Collection of all trusted mints informations
+ * Mints' URL,port,key triples
*/
struct MERCHANT_MintInfo *mint_infos;
@@ -232,10 +231,10 @@ url_handler (void *cls,
upload_data_size);
}
return TMH_MHD_handler_static_response (&h404,
- connection,
- con_cls,
- upload_data,
- upload_data_size);
+ connection,
+ con_cls,
+ upload_data,
+ upload_data_size);
}
@@ -292,55 +291,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
if (keyfile != NULL)
GNUNET_free (privkey);
-}
-/**
- * Debugging function which prints all non-null fields within
- * a mint descriptor. FIXME: Convert 'printf' in 'GNUNET_log'
- * @param mint mint whose values are getting dumped
- */
-void
-dump_mint (struct MERCHANT_MintInfo *mint)
-{
- char *dump;
- #define GET_MINT_VALUE_STRING(fieldname) \
- do { if (NULL != mint->fieldname) \
- { \
- dump = GNUNET_realloc (dump, strlen (dump) \
- + strlen (mint->fieldname) \
- + strlen (#fieldname ": ") \
- + 2); \
- sprintf (dump + strlen (dump), #fieldname ": %s\n", mint->fieldname); \
- } \
- } while (0);
-
- #define GET_MINT_VALUE_UINT16(fieldname) \
- do { if (0 != mint->fieldname && mint->fieldname < 65536) \
- { \
- dump = GNUNET_realloc (dump, strlen (dump) \
- + 5 \
- + strlen (#fieldname ": ") \
- + 2); \
- sprintf (dump + strlen (dump), #fieldname ": %d\n", mint->fieldname); \
- } \
- } while (0);
-
- dump = GNUNET_malloc (1);
-
- // TODO public key fetch
-
- GET_MINT_VALUE_STRING(city);
- GET_MINT_VALUE_STRING(province);
- GET_MINT_VALUE_UINT16(zip_code);
- GET_MINT_VALUE_UINT16(port);
- GET_MINT_VALUE_STRING(street);
- GET_MINT_VALUE_STRING(country);
- GET_MINT_VALUE_UINT16(street_no);
- printf ("country = %s\n", mint->country);
- printf ("Dumping mint:\n%s", dump);
- GNUNET_free (dump);
-
}
/**
@@ -365,8 +317,6 @@ run (void *cls, char *const *args, const char *cfgfile,
result = GNUNET_SYSERR;
shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&do_shutdown, NULL);
-
-
EXITIF (GNUNET_SYSERR == (nmints = TALER_MERCHANT_parse_mints (config,
&mint_infos)));
EXITIF (NULL == (wire = TALER_MERCHANT_parse_wireformat_sepa (config)));
@@ -398,38 +348,37 @@ run (void *cls, char *const *args, const char *cfgfile,
for (cnt = 0; cnt < nmints; cnt++)
{
- dump_mint (&mint_infos[cnt]);
-
struct Mint *mint;
struct GNUNET_HashCode mint_key;
mint = GNUNET_new (struct Mint);
mint->pubkey = mint_infos[cnt].pubkey;
-
/* port this to the new API */
-
- /* ToTest
mint->conn = TALER_MINT_connect (mctx,
mint_infos[cnt].hostname,
&keys_mgmt_cb,
- keys_mgmt_cls);
+ keys_mgmt_cls); /*<- safe?segfault friendly?*/
+
+ /* NOTE: the keys mgmt callback should roughly do what the following lines do */
EXITIF (NULL == mint->conn);
- */
- EXITIF (GNUNET_SYSERR ==
- GNUNET_CONTAINER_multipeermap_put (mints_map,
- (struct GNUNET_PeerIdentity *) &mint->pubkey,
- mint,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
-
- GNUNET_CRYPTO_hash (mint_infos[cnt].hostname,
- strlen (mint_infos[cnt].hostname),
- &mint_key);
-
- GNUNET_CONTAINER_multihashmap_put (mints_hashmap,
- &mint_key,
- &mint_infos[cnt],
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ EXITIF (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_put
+ (mints_map,
+ (struct GNUNET_PeerIdentity *) /* to retrieve now from cb's args -> */&mint->pubkey,
+ mint,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
+
+ /* 1 create hash key
+ 2 create big entry
+ 3 put
+ */
+ GNUNET_CRYPTO_hash (mint_infos[cnt].hostname,
+ strlen (mint_infos[cnt].hostname),
+ &mint_key);
+ GNUNET_CONTAINER_multihashmap_put (mints_hashmap,
+ &mint_key,
+ &mint_infos[cnt],
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
mhd = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY,