diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-23 19:16:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-23 19:16:04 +0000 |
commit | 39dac89da2eb7ceeb776ccdd6f663e2ab36acb1e (patch) | |
tree | dad81b14076d2e119b6faf413f3cefabdf8480c2 /src | |
parent | e5e33fe06042fe6c90f0a755a5c41f8f730c387c (diff) | |
download | gnunet-39dac89da2eb7ceeb776ccdd6f663e2ab36acb1e.tar.gz gnunet-39dac89da2eb7ceeb776ccdd6f663e2ab36acb1e.zip |
use messages with moderately futuristic timestamps
Diffstat (limited to 'src')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 23 |
1 files 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 @@ | |||
37 | * | 37 | * |
38 | * TODO: | 38 | * TODO: |
39 | * - generate proof-of-work asynchronously, store it on disk & load it back | 39 | * - generate proof-of-work asynchronously, store it on disk & load it back |
40 | * - handle messages for future round (one into the future, see FIXME) | ||
41 | */ | 40 | */ |
42 | #include "platform.h" | 41 | #include "platform.h" |
43 | #include "gnunet_util_lib.h" | 42 | #include "gnunet_util_lib.h" |
@@ -199,6 +198,11 @@ static double current_std_dev = NAN; | |||
199 | static uint32_t hop_count_max; | 198 | static uint32_t hop_count_max; |
200 | 199 | ||
201 | /** | 200 | /** |
201 | * Message for the next round, if we got any. | ||
202 | */ | ||
203 | static struct GNUNET_NSE_FloodMessage next_message; | ||
204 | |||
205 | /** | ||
202 | * Array of recent size estimate messages. | 206 | * Array of recent size estimate messages. |
203 | */ | 207 | */ |
204 | static struct GNUNET_NSE_FloodMessage size_estimate_messages[HISTORY_SIZE]; | 208 | static struct GNUNET_NSE_FloodMessage size_estimate_messages[HISTORY_SIZE]; |
@@ -632,7 +636,17 @@ update_flood_message(void *cls, | |||
632 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; | 636 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; |
633 | if (estimate_count < HISTORY_SIZE) | 637 | if (estimate_count < HISTORY_SIZE) |
634 | estimate_count++; | 638 | estimate_count++; |
635 | setup_flood_message (estimate_index, current_timestamp); | 639 | if (next_timestamp.abs_value == |
640 | GNUNET_TIME_absolute_ntoh (next_message.timestamp).abs_value) | ||
641 | { | ||
642 | /* we received a message for this round way early, use it! */ | ||
643 | size_estimate_messages[estimate_index] = next_message; | ||
644 | size_estimate_messages[estimate_index].hop_count | ||
645 | = htonl (1 + ntohl (next_message.hop_count)); | ||
646 | } | ||
647 | else | ||
648 | setup_flood_message (estimate_index, current_timestamp); | ||
649 | next_message.matching_bits = htonl (0); /* reset for 'next' round */ | ||
636 | hop_count_max = 0; | 650 | hop_count_max = 0; |
637 | for (i=0;i<HISTORY_SIZE;i++) | 651 | for (i=0;i<HISTORY_SIZE;i++) |
638 | hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), | 652 | hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), |
@@ -838,14 +852,15 @@ handle_p2p_size_estimate(void *cls, | |||
838 | idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE; | 852 | idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE; |
839 | else if (ts.abs_value == next_timestamp.abs_value - GNUNET_NSE_INTERVAL.rel_value) | 853 | else if (ts.abs_value == next_timestamp.abs_value - GNUNET_NSE_INTERVAL.rel_value) |
840 | { | 854 | { |
855 | if (matching_bits <= ntohl (next_message.matching_bits)) | ||
856 | return GNUNET_OK; /* ignore, simply too early */ | ||
841 | if (GNUNET_YES != | 857 | if (GNUNET_YES != |
842 | verify_message_crypto (incoming_flood)) | 858 | verify_message_crypto (incoming_flood)) |
843 | { | 859 | { |
844 | GNUNET_break_op (0); | 860 | GNUNET_break_op (0); |
845 | return GNUNET_OK; | 861 | return GNUNET_OK; |
846 | } | 862 | } |
847 | /* FIXME: keep in special 'future' buffer until next round starts for us! */ | 863 | next_message = *incoming_flood; |
848 | GNUNET_break (0); /* not implemented */ | ||
849 | return GNUNET_OK; | 864 | return GNUNET_OK; |
850 | } | 865 | } |
851 | else | 866 | else |