gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16153 - gnunet/src/nse


From: gnunet
Subject: [GNUnet-SVN] r16153 - gnunet/src/nse
Date: Sat, 23 Jul 2011 21:16:04 +0200

Author: grothoff
Date: 2011-07-23 21:16:04 +0200 (Sat, 23 Jul 2011)
New Revision: 16153

Modified:
   gnunet/src/nse/gnunet-service-nse.c
Log:
use messages with moderately futuristic timestamps

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2011-07-23 17:48:48 UTC (rev 16152)
+++ gnunet/src/nse/gnunet-service-nse.c 2011-07-23 19:16:04 UTC (rev 16153)
@@ -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"
@@ -199,6 +198,11 @@
 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.
  */
 static struct GNUNET_NSE_FloodMessage size_estimate_messages[HISTORY_SIZE];
@@ -632,7 +636,17 @@
   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<HISTORY_SIZE;i++)
     hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count),
@@ -838,14 +852,15 @@
     idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
   else if (ts.abs_value == next_timestamp.abs_value - 
GNUNET_NSE_INTERVAL.rel_value)
     {
+      if (matching_bits <= ntohl (next_message.matching_bits))
+       return GNUNET_OK; /* ignore, simply too early */      
       if (GNUNET_YES !=
          verify_message_crypto (incoming_flood))
        {
          GNUNET_break_op (0);
          return GNUNET_OK;
        }
-      /* FIXME: keep in special 'future' buffer until next round starts for 
us! */
-      GNUNET_break (0); /* not implemented */
+      next_message = *incoming_flood;
       return GNUNET_OK;
     }
   else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]