From 39dac89da2eb7ceeb776ccdd6f663e2ab36acb1e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Jul 2011 19:16:04 +0000 Subject: [PATCH] use messages with moderately futuristic timestamps --- src/nse/gnunet-service-nse.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 1d5421acb..c690eb1e2 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -37,7 +37,6 @@ * * TODO: * - generate proof-of-work asynchronously, store it on disk & load it back - * - handle messages for future round (one into the future, see FIXME) */ #include "platform.h" #include "gnunet_util_lib.h" @@ -198,6 +197,11 @@ static double current_std_dev = NAN; */ static uint32_t hop_count_max; +/** + * Message for the next round, if we got any. + */ +static struct GNUNET_NSE_FloodMessage next_message; + /** * Array of recent size estimate messages. */ @@ -632,7 +636,17 @@ update_flood_message(void *cls, estimate_index = (estimate_index + 1) % HISTORY_SIZE; if (estimate_count < HISTORY_SIZE) estimate_count++; - setup_flood_message (estimate_index, current_timestamp); + if (next_timestamp.abs_value == + GNUNET_TIME_absolute_ntoh (next_message.timestamp).abs_value) + { + /* we received a message for this round way early, use it! */ + size_estimate_messages[estimate_index] = next_message; + size_estimate_messages[estimate_index].hop_count + = htonl (1 + ntohl (next_message.hop_count)); + } + else + setup_flood_message (estimate_index, current_timestamp); + next_message.matching_bits = htonl (0); /* reset for 'next' round */ hop_count_max = 0; for (i=0;i