gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r13020 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r13020 - gnunet/src/fs
Date: Sat, 18 Sep 2010 06:49:08 +0200

Author: grothoff
Date: 2010-09-18 06:49:08 +0200 (Sat, 18 Sep 2010)
New Revision: 13020

Modified:
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/gnunet-service-fs.c
Log:
use block lib some more

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2010-09-18 04:48:58 UTC (rev 13019)
+++ gnunet/src/fs/fs_publish.c  2010-09-18 04:49:08 UTC (rev 13020)
@@ -1639,6 +1639,7 @@
   char *kbe;
   char *sptr;
 
+  GNUNET_assert (NULL != uri);
   pkc = GNUNET_malloc (sizeof (struct PublishKskContext));
   pkc->h = h;
   pkc->expirationTime = expirationTime;

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-09-18 04:48:58 UTC (rev 13019)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-09-18 04:49:08 UTC (rev 13020)
@@ -1787,23 +1787,6 @@
 
 
 /**
- * Mingle hash with the mingle_number to produce different bits.
- */
-static void
-mingle_hash (const GNUNET_HashCode * in,
-            int32_t mingle_number, 
-            GNUNET_HashCode * hc)
-{
-  GNUNET_HashCode m;
-
-  GNUNET_CRYPTO_hash (&mingle_number, 
-                     sizeof (int32_t), 
-                     &m);
-  GNUNET_CRYPTO_hash_xor (&m, in, hc);
-}
-
-
-/**
  * Test if the load on this peer is too high
  * to even consider processing the query at
  * all.
@@ -1965,7 +1948,9 @@
                                              BLOOMFILTER_K);
   for (i=0;i<pr->replies_seen_off;i++)
     {
-      mingle_hash (&pr->replies_seen[i], pr->mingle, &mhash);
+      GNUNET_BLOCK_mingle_hash (&pr->replies_seen[i],
+                               pr->mingle,
+                               &mhash);
       GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
     }
 }
@@ -2534,8 +2519,7 @@
   struct PutMessage *pm;
   struct ConnectedPeer *cp;
   struct GNUNET_TIME_Relative cur_delay;
-  GNUNET_HashCode chash;
-  GNUNET_HashCode mhash;
+  enum GNUNET_BLOCK_EvaluationResult eval;
   size_t msize;
 
 #if DEBUG_FS
@@ -2581,9 +2565,6 @@
          GNUNET_SERVER_client_keep 
(pr->client_request_list->client_list->client);
        }
     }
-  GNUNET_CRYPTO_hash (prq->data,
-                     prq->size,
-                     &chash);
   switch (prq->type)
     {
     case GNUNET_BLOCK_TYPE_DBLOCK:
@@ -2617,39 +2598,96 @@
          GNUNET_break (0);
          return GNUNET_YES;
        }
-      if (0 != memcmp (pr->namespace,
-                      &prq->namespace,
-                      sizeof (GNUNET_HashCode)))
+      eval = GNUNET_BLOCK_evaluate (block_ctx,
+                                   prq->type,
+                                   key,
+                                   &pr->bf,
+                                   pr->mingle,
+                                   pr->namespace, sizeof (GNUNET_HashCode),
+                                   prq->data,
+                                   prq->size);
+      switch (eval)
        {
-         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                     _("Reply mismatched in terms of namespace.  
Discarded.\n"));
+       case GNUNET_BLOCK_EVALUATION_OK_MORE:
+         break;
+       case GNUNET_BLOCK_EVALUATION_OK_LAST:
+         break;
+       case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+         GNUNET_STATISTICS_update (stats,
+                                   gettext_noop ("# duplicate replies 
discarded (bloomfilter)"),
+                                   1,
+                                   GNUNET_NO);
+#if DEBUG_FS
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Duplicate response `%s', discarding.\n",
+                     GNUNET_h2s (&mhash));
+#endif
+         return GNUNET_YES; /* duplicate */
+       case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
          return GNUNET_YES; /* wrong namespace */      
+       case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
+         GNUNET_break (0);
+         return GNUNET_YES;
+        case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
+          GNUNET_break (0);
+          return GNUNET_YES;
+       case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Block library does not support FS blocks\n"));
+         return GNUNET_NO;
        }
-      /* then: fall-through! */
+      if (pr->client_request_list != NULL)
+       {
+         if (pr->replies_seen_size == pr->replies_seen_off)
+           GNUNET_array_grow (pr->replies_seen,
+                              pr->replies_seen_size,
+                              pr->replies_seen_size * 2 + 4);  
+           GNUNET_CRYPTO_hash (prq->data,
+                               prq->size,
+                               &pr->replies_seen[pr->replies_seen_off++]);     
      
+           refresh_bloomfilter (pr);
+       }
+      break;
     case GNUNET_BLOCK_TYPE_KBLOCK:
     case GNUNET_BLOCK_TYPE_NBLOCK:
-      if (pr->bf != NULL) 
+      eval = GNUNET_BLOCK_evaluate (block_ctx,
+                                   prq->type,
+                                   key,
+                                   &pr->bf,
+                                   pr->mingle,
+                                   NULL, 0,
+                                   prq->data,
+                                   prq->size);
+      switch (eval)
        {
-         mingle_hash (&chash, pr->mingle, &mhash);
-         if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (pr->bf,
-                                                              &mhash))
-           {
-             GNUNET_STATISTICS_update (stats,
-                                       gettext_noop ("# duplicate replies 
discarded (bloomfilter)"),
-                                       1,
-                                       GNUNET_NO);
+       case GNUNET_BLOCK_EVALUATION_OK_MORE:
+         break;
+       case GNUNET_BLOCK_EVALUATION_OK_LAST:
+         break;
+       case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+         GNUNET_STATISTICS_update (stats,
+                                   gettext_noop ("# duplicate replies 
discarded (bloomfilter)"),
+                                   1,
+                                   GNUNET_NO);
 #if DEBUG_FS
-             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                         "Duplicate response `%s', discarding.\n",
-                         GNUNET_h2s (&mhash));
-#endif
-             return GNUNET_YES; /* duplicate */
-           }
-#if DEBUG_FS
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                     "New response `%s', adding to filter.\n",
+                     "Duplicate response `%s', discarding.\n",
                      GNUNET_h2s (&mhash));
 #endif
+         return GNUNET_YES; /* duplicate */
+       case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
+         GNUNET_break_op (0);
+         return GNUNET_YES;
+       case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
+         GNUNET_break (0);
+         return GNUNET_YES;
+        case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
+          GNUNET_break (0);
+          return GNUNET_YES;
+       case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Block library does not support FS blocks\n"));
+         return GNUNET_NO;
        }
       if (pr->client_request_list != NULL)
        {
@@ -2657,13 +2695,11 @@
            GNUNET_array_grow (pr->replies_seen,
                               pr->replies_seen_size,
                               pr->replies_seen_size * 2 + 4);  
-           pr->replies_seen[pr->replies_seen_off++] = chash;         
+           GNUNET_CRYPTO_hash (prq->data,
+                               prq->size,
+                               &pr->replies_seen[pr->replies_seen_off++]);     
      
+           refresh_bloomfilter (pr);
        }
-      if ( (pr->bf == NULL) ||
-          (pr->client_request_list != NULL) )
-       refresh_bloomfilter (pr);
-      GNUNET_CONTAINER_bloomfilter_add (pr->bf,
-                                       &mhash);
       break;
     default:
       GNUNET_break (0);
@@ -3027,9 +3063,9 @@
     }
   /* check for duplicates */
   GNUNET_CRYPTO_hash (data, size, &dhash);
-  mingle_hash (&dhash, 
-              pr->mingle,
-              &mhash);
+  GNUNET_BLOCK_mingle_hash (&dhash, 
+                           pr->mingle,
+                           &mhash);
   if ( (pr->bf != NULL) &&
        (GNUNET_YES ==
        GNUNET_CONTAINER_bloomfilter_test (pr->bf,




reply via email to

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