#include "gnunet_dht_service.h"
/* DEFINES */
-#define VERBOSE GNUNET_EXTRA_LOGGING
-
#define MAX_GET_ATTEMPTS 10
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
{
const char *emsg = cls;
- fprintf (stderr, "Error: %s\n", emsg);
+ FPRINTF (stderr, "Error: %s\n", emsg);
if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
*/
static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
- const GNUNET_HashCode * key,
+ const struct GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
struct PeerGetContext *get_context = cls;
if (0 !=
- memcmp (&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode)))
+ memcmp (&get_context->peer->hashPubKey, key, sizeof (struct GNUNET_HashCode)))
{
- fprintf (stderr, "??\n");
+ FPRINTF (stderr, "%s", "??\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Key returned is not the same key as was searched for!\n");
GNUNET_SCHEDULER_cancel (die_task);
"key mismatch in get response!\n");
return;
}
- fprintf (stderr, "!\n");
if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (get_context->retry_task);
{
struct PeerGetContext *get_context = cls;
- if (get_context->get_attempts < MAX_GET_ATTEMPTS)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Get attempt %u failed, retrying request!\n",
- get_context->get_attempts);
- else
+ if (get_context->get_attempts >= MAX_GET_ATTEMPTS)
{
- fprintf (stderr, "?\n");
+ FPRINTF (stderr, "%s", "?\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Too many attempts failed, ending test!\n",
get_context->get_attempts);
"GET attempt failed, ending test!\n");
return;
}
- fprintf (stderr, ".");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Get attempt %u failed, retrying request!\n",
+ get_context->get_attempts);
+ FPRINTF (stderr, "%s", ".");
get_context->get_attempts++;
get_context->retry_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 10),
+ (GNUNET_TIME_UNIT_SECONDS, 60),
&stop_retry_get, get_context);
get_context->get_handle =
GNUNET_DHT_get_start (get_context->dht_handle,
- GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
&get_context->peer->hashPubKey, 1,
GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator,
&stop_retry_get, get_context);
get_context->get_handle =
GNUNET_DHT_get_start (get_context->dht_handle,
- GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
&get_context->peer->hashPubKey, 1,
GNUNET_DHT_RO_FIND_PEER, NULL, 0,
if (emsg == NULL)
{
total_connections++;
-#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"connected peer %s to peer %s, distance %u\n",
first_daemon->shortname, second_daemon->shortname, distance);
-#endif
}
-#if VERBOSE
else
{
failed_connections++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to connect peer %s to peer %s with error :\n%s\n",
first_daemon->shortname, second_daemon->shortname, emsg);
}
-#endif
if (total_connections == expected_connections)
{
-#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created %d total connections, which is our target number! Starting next phase of testing.\n",
total_connections);
-#endif
GNUNET_SCHEDULER_cancel (die_task);
die_task =
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
{
if (emsg != NULL)
{
- fprintf (stderr, "Failed to start daemon: `%s'\n", emsg);
+ FPRINTF (stderr, "Failed to start daemon: `%s'\n", emsg);
return;
}
GNUNET_assert (id != NULL);
if (peers_left == 0)
{
-#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"All %d daemons started, now connecting peers!\n", num_peers);
-#endif
GNUNET_SCHEDULER_cancel (die_task);
/* Set up task in case topology creation doesn't finish
* within a reasonable amount of time */
}
if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
+ GNUNET_CONFIGURATION_get_value_number (cfg, "testing_old", "num_peers",
&num_peers))
num_peers = DEFAULT_NUM_PEERS;
char *const argv[] = { "test-dht-twopeer",
"-c",
"test_dht_twopeer_data.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
int ret;
GNUNET_log_setup ("test-dht-twopeer",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
ret = check ();
/**