gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8255 - GNUnet/src/applications/dv/module


From: gnunet
Subject: [GNUnet-SVN] r8255 - GNUnet/src/applications/dv/module
Date: Mon, 16 Feb 2009 13:00:09 -0700

Author: nevans
Date: 2009-02-16 13:00:09 -0700 (Mon, 16 Feb 2009)
New Revision: 8255

Modified:
   GNUnet/src/applications/dv/module/dv.c
   GNUnet/src/applications/dv/module/dv_heaptest.c
   GNUnet/src/applications/dv/module/heap.c
   GNUnet/src/applications/dv/module/heap.h
Log:
fisheye distance vector updates

Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c      2009-02-16 19:59:37 UTC (rev 
8254)
+++ GNUnet/src/applications/dv/module/dv.c      2009-02-16 20:00:09 UTC (rev 
8255)
@@ -29,12 +29,17 @@
 #include "gnunet_protocols.h"
 #include "gnunet_util.h"
 #include "gnunet_core.h"
+#include "gnunet_dv_lib.h"
 #include "dv.h"
 #include "heap.h"
 
 #define DEBUG_DV
+/* How long to allow a message to be delayed */
+#define DV_DELAY (100 * GNUNET_CRON_MILLISECONDS)
 
-
+/*
+ * Global construct
+ */
 struct GNUNET_DV_Context
 {
   unsigned long long fisheye_depth;
@@ -104,16 +109,104 @@
   return;
 }
 
+
 /*
+ * Handle a message receipt, if recipient matches ident message is
+ * for this peer, otherwise check if we know of the intended
+ * recipient and send onwards
+ */
 static int
-p2pHandleDVRouteMessage (const GNUNET_PeerIdentity * sender,
-                            const GNUNET_MessageHeader * message)
+p2pHandleDVDataMessage (const GNUNET_PeerIdentity * sender,
+                        const GNUNET_MessageHeader * message)
 {
+  p2p_dv_MESSAGE_Data *incoming;
+  incoming = (p2p_dv_MESSAGE_Data *) message;
+  char *message_content;
+  unsigned int message_length;
+  int ret;
 
-       return GNUNET_OK;
+  ret = GNUNET_OK;
+  if (ntohs (incoming->header.size) < sizeof (p2p_dv_MESSAGE_Data))
+    {
+      return GNUNET_SYSERR;
+    }
+
+  message_length =
+    ntohs (incoming->header.size) - sizeof (p2p_dv_MESSAGE_Data);
+  message_content = GNUNET_malloc (message_length + 1);
+  memcpy (message_content, &incoming[1], message_length);
+  message_content[message_length] = '\0';
+
+  if (memcmp
+      (coreAPI->my_identity, &incoming->recipient,
+       sizeof (GNUNET_PeerIdentity)) == 0)
+    {
+      /*FIXME: Deliver message up to ???  Handle arbitrary messages? */
+#ifdef DEBUG_DV
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                     GNUNET_GE_BULK,
+                     "Received message %s intended for this node!\n",
+                     message_content);
+#endif
+    }
+  else
+    {
+#ifdef DEBUG_DV
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                     GNUNET_GE_BULK,
+                     "Received message %s for some other node!\n",
+                     message_content);
+#endif
+      ret = GNUNET_DV_send_message (&incoming->recipient, message_content);
+    }
+  GNUNET_free (message_content);
+  return ret;
 }
-*/
 
+
+int
+GNUNET_DV_send_message (const GNUNET_PeerIdentity * recipient, char *message)
+{
+  p2p_dv_MESSAGE_Data *toSend;
+  int ret = GNUNET_OK;
+  unsigned int msg_size;
+  struct GNUNET_dv_neighbor *neighbor;
+
+  if (GNUNET_YES ==
+      GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
+                                      &recipient->hashPubKey))
+    {
+      neighbor =
+        GNUNET_multi_hash_map_get (ctx->extended_neighbors,
+                                   &recipient->hashPubKey);
+      msg_size = strlen (message) + sizeof (p2p_dv_MESSAGE_Data);
+      if (msg_size > GNUNET_MAX_BUFFER_SIZE - 8)
+        return GNUNET_SYSERR;
+      toSend = GNUNET_malloc (msg_size);
+      toSend->header.size = htons (msg_size);
+      toSend->header.type = htons (GNUNET_P2P_PROTO_DV_DATA_MESSAGE);
+      memcpy (&toSend->recipient, recipient, sizeof (GNUNET_PeerIdentity));
+      memcpy (&toSend[1], message, strlen (message));
+      coreAPI->ciphertext_send (neighbor->neighbor, &toSend->header, 0,
+                                DV_DELAY);
+      GNUNET_free (toSend);
+      return ret;
+    }
+  else
+    {
+#ifdef DEBUG_DV
+      GNUNET_GE_LOG (coreAPI->ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+                     GNUNET_GE_BULK,
+                     "Attempted to send a message to an unknown peer!\n");
+#endif
+      return GNUNET_NO;
+    }
+
+}
+
 /*
  * Handles when a peer is either added due to being newly connected
  * or having been gossiped about, also called when a cost for a neighbor
@@ -208,7 +301,8 @@
           if (neighbor->referrer != NULL)
             GNUNET_free (neighbor->referrer);
           GNUNET_free (neighbor);
-          GNUNET_multi_hash_map_remove_all(ctx->extended_neighbors, 
&peer->hashPubKey);
+          GNUNET_multi_hash_map_remove_all (ctx->extended_neighbors,
+                                            &peer->hashPubKey);
 
           neighbor = GNUNET_malloc (sizeof (struct GNUNET_dv_neighbor));
           neighbor->cost = cost;
@@ -323,9 +417,9 @@
       if (neighbor->cost != cost)
         {
           neighbor->cost = cost;
-        /*GNUNET_multi_hash_map_put (ctx->direct_neighbors, &peer->hashPubKey,
-                                     neighbor,
-                                     GNUNET_MultiHashMapOption_REPLACE);*/
+          /*GNUNET_multi_hash_map_put (ctx->direct_neighbors, 
&peer->hashPubKey,
+             neighbor,
+             GNUNET_MultiHashMapOption_REPLACE); */
         }
 
     }
@@ -334,8 +428,8 @@
 
 #ifdef DEBUG_DV
   GNUNET_mutex_lock (ctx->dvMutex);
-       print_tables ();
-       GNUNET_mutex_unlock (ctx->dvMutex);
+  print_tables ();
+  GNUNET_mutex_unlock (ctx->dvMutex);
 #endif
   return;
 
@@ -368,11 +462,13 @@
 #endif
 
   if (((memcmp (neighbor->neighbor, toMatch, sizeof (GNUNET_PeerIdentity)) ==
-       0) && (neighbor->referrer == NULL)) || ((neighbor->referrer != NULL)
-              &&
-              (memcmp
-               (neighbor->referrer, toMatch,
-                sizeof (GNUNET_PeerIdentity)) == 0)))
+        0) && (neighbor->referrer == NULL)) || ((neighbor->referrer != NULL)
+                                                &&
+                                                (memcmp
+                                                 (neighbor->referrer, toMatch,
+                                                  sizeof
+                                                  (GNUNET_PeerIdentity)) ==
+                                                 0)))
     {
       GNUNET_DV_Heap_removeNode (&ctx->neighbor_max_heap, neighbor);
       GNUNET_DV_Heap_removeNode (&ctx->neighbor_min_heap, neighbor);
@@ -409,8 +505,8 @@
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "disconnected peer: %s\n", (char *) &myself);
   GNUNET_mutex_lock (ctx->dvMutex);
-       print_tables ();
-       GNUNET_mutex_unlock (ctx->dvMutex);
+  print_tables ();
+  GNUNET_mutex_unlock (ctx->dvMutex);
 #endif
 
   GNUNET_mutex_lock (ctx->dvMutex);
@@ -423,7 +519,7 @@
         GNUNET_multi_hash_map_get (ctx->direct_neighbors, &peer->hashPubKey);
 
       GNUNET_multi_hash_map_remove_all (ctx->direct_neighbors,
-                                                  &peer->hashPubKey);
+                                        &peer->hashPubKey);
       if (neighbor != NULL)
         {
           GNUNET_DV_Heap_Iterator (&ctx->neighbor_max_heap,
@@ -442,8 +538,8 @@
   GNUNET_mutex_unlock (ctx->dvMutex);
 #ifdef DEBUG_DV
   GNUNET_mutex_lock (ctx->dvMutex);
-       print_tables ();
-       GNUNET_mutex_unlock (ctx->dvMutex);
+  print_tables ();
+  GNUNET_mutex_unlock (ctx->dvMutex);
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                  GNUNET_GE_BULK, "Exiting peer_disconnect_handler\n");
@@ -611,7 +707,12 @@
       (GNUNET_P2P_PROTO_DV_NEIGHBOR_MESSAGE, &p2pHandleDVNeighborMessage))
     ok = GNUNET_SYSERR;
 
+  if (GNUNET_SYSERR ==
+      coreAPI->p2p_ciphertext_handler_register
+      (GNUNET_P2P_PROTO_DV_DATA_MESSAGE, &p2pHandleDVDataMessage))
+    ok = GNUNET_SYSERR;
 
+
   sendingThread =
     GNUNET_thread_create (&neighbor_send_thread, &coreAPI, 1024 * 1);
 

Modified: GNUnet/src/applications/dv/module/dv_heaptest.c
===================================================================
--- GNUnet/src/applications/dv/module/dv_heaptest.c     2009-02-16 19:59:37 UTC 
(rev 8254)
+++ GNUnet/src/applications/dv/module/dv_heaptest.c     2009-02-16 20:00:09 UTC 
(rev 8255)
@@ -39,7 +39,7 @@
 
 static int
 count_max_callback (struct GNUNET_dv_neighbor *neighbor,
-                 struct GNUNET_dv_heap *root, void *cls)
+                    struct GNUNET_dv_heap *root, void *cls)
 {
   tempmaxsize++;
   return 1;
@@ -47,41 +47,48 @@
 
 static int
 count_min_callback (struct GNUNET_dv_neighbor *neighbor,
-                 struct GNUNET_dv_heap *root, void *cls)
+                    struct GNUNET_dv_heap *root, void *cls)
 {
   tempminsize++;
   return 1;
 }
 
-static int heap_verify_callback(struct GNUNET_dv_neighbor *neighbor,
-    struct GNUNET_dv_heap *root, void *cls)
+static int
+heap_verify_callback (struct GNUNET_dv_neighbor *neighbor,
+                      struct GNUNET_dv_heap *root, void *cls)
 {
   int ret;
   ret = heapverify;
   if (root->type == GNUNET_DV_MAX_HEAP)
-  {
-    if ((neighbor->max_loc->left_child != NULL) && (neighbor->cost < 
neighbor->max_loc->left_child->neighbor->cost))
     {
-      ret = GNUNET_SYSERR;
-    }
+      if ((neighbor->max_loc->left_child != NULL)
+          && (neighbor->cost < neighbor->max_loc->left_child->neighbor->cost))
+        {
+          ret = GNUNET_SYSERR;
+        }
 
-    if ((neighbor->max_loc->right_child != NULL) && (neighbor->cost < 
neighbor->max_loc->right_child->neighbor->cost))
-    {
-      ret = GNUNET_SYSERR;
+      if ((neighbor->max_loc->right_child != NULL)
+          && (neighbor->cost <
+              neighbor->max_loc->right_child->neighbor->cost))
+        {
+          ret = GNUNET_SYSERR;
+        }
     }
-  }
   else if (root->type == GNUNET_DV_MIN_HEAP)
-  {
-    if ((neighbor->min_loc->left_child != NULL) && (neighbor->cost > 
neighbor->min_loc->left_child->neighbor->cost))
     {
-      ret = GNUNET_SYSERR;
-    }
+      if ((neighbor->min_loc->left_child != NULL)
+          && (neighbor->cost > neighbor->min_loc->left_child->neighbor->cost))
+        {
+          ret = GNUNET_SYSERR;
+        }
 
-    if ((neighbor->min_loc->right_child != NULL) && (neighbor->cost > 
neighbor->min_loc->right_child->neighbor->cost))
-    {
-      ret = GNUNET_SYSERR;
+      if ((neighbor->min_loc->right_child != NULL)
+          && (neighbor->cost >
+              neighbor->min_loc->right_child->neighbor->cost))
+        {
+          ret = GNUNET_SYSERR;
+        }
     }
-  }
 
   heapverify = ret;
   return ret;
@@ -97,9 +104,11 @@
   return GNUNET_OK;
 }
 
-static int check_node(struct GNUNET_dv_neighbor *neighbor)
+static int
+check_node (struct GNUNET_dv_neighbor *neighbor)
 {
-  if ((neighbor->max_loc->neighbor == neighbor) && 
(neighbor->min_loc->neighbor == neighbor))
+  if ((neighbor->max_loc->neighbor == neighbor)
+      && (neighbor->min_loc->neighbor == neighbor))
     return GNUNET_OK;
   else
     return GNUNET_SYSERR;
@@ -136,102 +145,114 @@
   minHeap->size = 0;
   minHeap->traversal_pos = NULL;
 
-  for (i = 0;i<TESTS;i++)
-  {
-    neighbors[i] = NULL;
-  }
-
-  for (i = 0;i<TESTS;i++)
-  //for (i = 0;i<6;i++)
-  {
-    temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
-    while((cur_pos <= 1) && (temp_rand != 0))
-      temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
-    //temp_rand = seq[i];
-    switch(temp_rand)
+  for (i = 0; i < TESTS; i++)
     {
-      case 0:
-      case 1:
-        temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) + 1;
-        fprintf(stderr, "Adding node with cost %d\n", temp_rand);
-        neighbors[cur_pos] = malloc(sizeof (struct GNUNET_dv_neighbor));
-        neighbors[cur_pos]->neighbor = malloc(sizeof(GNUNET_PeerIdentity));
-        hostkey = GNUNET_RSA_create_key();
-        GNUNET_RSA_get_public_key (hostkey, &pubkey);
-        GNUNET_hash (&pubkey, sizeof (GNUNET_RSA_PublicKey), 
&neighbors[cur_pos]->neighbor->hashPubKey);
-        //neighbors[cur_pos]->cost = temp_rand;
-        neighbors[cur_pos]->cost = temp_rand;
-        GNUNET_DV_Heap_insert (maxHeap, neighbors[cur_pos]);
-        GNUNET_DV_Heap_insert (minHeap, neighbors[cur_pos]);
-        cur_pos++;
-        break;
-
-      case 2:
-        temp_node = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, cur_pos);
-        temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) + 1;
-        fprintf(stderr, "Updating node %d (cost %d) with new cost %d\n", 
temp_node + 1, neighbors[temp_node]->cost ,temp_rand);
-        GNUNET_DV_Heap_updateCost(maxHeap, neighbors[temp_node], temp_rand);
-        GNUNET_DV_Heap_updatedCost(minHeap, neighbors[temp_node]);
-        break;
-      case 3:
-        fprintf(stderr, "Removing node %d with cost %d\n", cur_pos, 
neighbors[cur_pos - 1]->cost);
-        GNUNET_DV_Heap_removeNode(maxHeap, neighbors[cur_pos - 1]);
-        GNUNET_DV_Heap_removeNode(minHeap, neighbors[cur_pos - 1]);
-        GNUNET_free(neighbors[cur_pos - 1]->neighbor);
-        GNUNET_free(neighbors[cur_pos - 1]);
-        neighbors[cur_pos - 1] = NULL;
-        cur_pos--;
-        break;
-      case 4:
-        //fprintf(stderr, "Removing matching nodes\n");
-        break;
+      neighbors[i] = NULL;
     }
 
-    for (j = 0;j<cur_pos;j++)
+  for (i = 0; i < TESTS; i++)
+    //for (i = 0;i<6;i++)
     {
-      if(check_node(neighbors[j]) != GNUNET_OK)
-      {
-        fprintf(stderr, "\n\n\tEPIC FAIL\n\n");
-        if ((neighbors[j]->max_loc->neighbor != neighbors[j]))
+      temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
+      while ((cur_pos <= 1) && (temp_rand != 0))
+        temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 5);
+      //temp_rand = seq[i];
+      switch (temp_rand)
         {
-          fprintf(stderr, "node at position %d has bad max_loc\n", j);
+        case 0:
+        case 1:
+          temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) + 1;
+          fprintf (stderr, "Adding node with cost %d\n", temp_rand);
+          neighbors[cur_pos] = malloc (sizeof (struct GNUNET_dv_neighbor));
+          neighbors[cur_pos]->neighbor =
+            malloc (sizeof (GNUNET_PeerIdentity));
+          hostkey = GNUNET_RSA_create_key ();
+          GNUNET_RSA_get_public_key (hostkey, &pubkey);
+          GNUNET_hash (&pubkey, sizeof (GNUNET_RSA_PublicKey),
+                       &neighbors[cur_pos]->neighbor->hashPubKey);
+          //neighbors[cur_pos]->cost = temp_rand;
+          neighbors[cur_pos]->cost = temp_rand;
+          GNUNET_DV_Heap_insert (maxHeap, neighbors[cur_pos]);
+          GNUNET_DV_Heap_insert (minHeap, neighbors[cur_pos]);
+          cur_pos++;
+          break;
+
+        case 2:
+          temp_node = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, cur_pos);
+          temp_rand = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100) + 1;
+          fprintf (stderr, "Updating node %d (cost %d) with new cost %d\n",
+                   temp_node + 1, neighbors[temp_node]->cost, temp_rand);
+          GNUNET_DV_Heap_updateCost (maxHeap, neighbors[temp_node],
+                                     temp_rand);
+          GNUNET_DV_Heap_updatedCost (minHeap, neighbors[temp_node]);
+          break;
+        case 3:
+          fprintf (stderr, "Removing node %d with cost %d\n", cur_pos,
+                   neighbors[cur_pos - 1]->cost);
+          GNUNET_DV_Heap_removeNode (maxHeap, neighbors[cur_pos - 1]);
+          GNUNET_DV_Heap_removeNode (minHeap, neighbors[cur_pos - 1]);
+          GNUNET_free (neighbors[cur_pos - 1]->neighbor);
+          GNUNET_free (neighbors[cur_pos - 1]);
+          neighbors[cur_pos - 1] = NULL;
+          cur_pos--;
+          break;
+        case 4:
+          //fprintf(stderr, "Removing matching nodes\n");
+          break;
         }
-        if (neighbors[j]->min_loc->neighbor != neighbors[j])
+
+      for (j = 0; j < cur_pos; j++)
         {
-          fprintf(stderr, "node at position %d has bad min_loc\n", j);
+          if (check_node (neighbors[j]) != GNUNET_OK)
+            {
+              fprintf (stderr, "\n\n\tEPIC FAIL\n\n");
+              if ((neighbors[j]->max_loc->neighbor != neighbors[j]))
+                {
+                  fprintf (stderr, "node at position %d has bad max_loc\n",
+                           j);
+                }
+              if (neighbors[j]->min_loc->neighbor != neighbors[j])
+                {
+                  fprintf (stderr, "node at position %d has bad min_loc\n",
+                           j);
+                }
+              ret = GNUNET_SYSERR;
+            }
         }
-        ret = GNUNET_SYSERR;
-      }
-    }
-    heapverify = GNUNET_OK;
-    GNUNET_DV_Heap_Iterator(minHeap, minHeap->root, &heap_verify_callback, 
NULL);
-    if (heapverify != GNUNET_OK)
-    {
-      fprintf(stderr, "Min heap property broken!\n");
-      return GNUNET_SYSERR;
-    }
+      heapverify = GNUNET_OK;
+      GNUNET_DV_Heap_Iterator (minHeap, minHeap->root, &heap_verify_callback,
+                               NULL);
+      if (heapverify != GNUNET_OK)
+        {
+          fprintf (stderr, "Min heap property broken!\n");
+          return GNUNET_SYSERR;
+        }
 
-    GNUNET_DV_Heap_Iterator(maxHeap, maxHeap->root, &heap_verify_callback, 
NULL);
-    if (heapverify != GNUNET_OK)
-    {
-      fprintf(stderr, "Max heap property broken!\n");
-      return GNUNET_SYSERR;
-    }
+      GNUNET_DV_Heap_Iterator (maxHeap, maxHeap->root, &heap_verify_callback,
+                               NULL);
+      if (heapverify != GNUNET_OK)
+        {
+          fprintf (stderr, "Max heap property broken!\n");
+          return GNUNET_SYSERR;
+        }
 
-    if (ret != GNUNET_OK)
-      return GNUNET_SYSERR;
+      if (ret != GNUNET_OK)
+        return GNUNET_SYSERR;
 
-    tempmaxsize = 0;
-    tempminsize = 0;
-    GNUNET_DV_Heap_Iterator(maxHeap, maxHeap->root, &count_max_callback, NULL);
-    GNUNET_DV_Heap_Iterator(minHeap, minHeap->root, &count_min_callback, NULL);
+      tempmaxsize = 0;
+      tempminsize = 0;
+      GNUNET_DV_Heap_Iterator (maxHeap, maxHeap->root, &count_max_callback,
+                               NULL);
+      GNUNET_DV_Heap_Iterator (minHeap, minHeap->root, &count_min_callback,
+                               NULL);
 
-    if ((tempmaxsize != cur_pos) || (tempminsize != cur_pos) || (maxHeap->size 
!= cur_pos) || (minHeap->size != cur_pos))
-    {
-      fprintf(stderr, "Incorrect heap sizes!\n");
-      return GNUNET_SYSERR;
+      if ((tempmaxsize != cur_pos) || (tempminsize != cur_pos)
+          || (maxHeap->size != cur_pos) || (minHeap->size != cur_pos))
+        {
+          fprintf (stderr, "Incorrect heap sizes!\n");
+          return GNUNET_SYSERR;
+        }
     }
-  }
 
   return 0;
 }

Modified: GNUnet/src/applications/dv/module/heap.c
===================================================================
--- GNUnet/src/applications/dv/module/heap.c    2009-02-16 19:59:37 UTC (rev 
8254)
+++ GNUnet/src/applications/dv/module/heap.c    2009-02-16 20:00:09 UTC (rev 
8255)
@@ -34,19 +34,19 @@
 printTree (struct GNUNET_dv_heap_node *root)
 {
   if (root->neighbor != NULL)
-         {
-           fprintf (stdout, "%d\n", root->neighbor->cost);
-         if (root->left_child != NULL)
-           {
-             fprintf (stdout, "LEFT of %d\n", root->neighbor->cost);
-             printTree (root->left_child);
-           }
-         if (root->right_child != NULL)
-           {
-             fprintf (stdout, "RIGHT of %d\n", root->neighbor->cost);
-             printTree (root->right_child);
-           }
-         }
+    {
+      fprintf (stdout, "%d\n", root->neighbor->cost);
+      if (root->left_child != NULL)
+        {
+          fprintf (stdout, "LEFT of %d\n", root->neighbor->cost);
+          printTree (root->left_child);
+        }
+      if (root->right_child != NULL)
+        {
+          fprintf (stdout, "RIGHT of %d\n", root->neighbor->cost);
+          printTree (root->right_child);
+        }
+    }
 }
 
 static struct GNUNET_dv_heap_node *

Modified: GNUnet/src/applications/dv/module/heap.h
===================================================================
--- GNUnet/src/applications/dv/module/heap.h    2009-02-16 19:59:37 UTC (rev 
8254)
+++ GNUnet/src/applications/dv/module/heap.h    2009-02-16 20:00:09 UTC (rev 
8255)
@@ -87,10 +87,8 @@
 };
 
 /** FIXME:
- * Smart heap iterator and iterate functions are literal
- * prototypes, they are not yet implemented!!!  Heap needs
- * to be de-DV-ified.  Just here to remind me (nate) that
- * it still needs done!!!!!!!!!!!!!!
+ * Heap needs to be de-DV-ified.  Just here to remind me
+ * (nate) that it still needs done!!!!!!!!!!!!!!
  */
 
 /**
@@ -120,6 +118,7 @@
 
 /**
  * Simple stupid tree print.  Prints in depth first order.
+ * To stdout.
  */
 void printTree (struct GNUNET_dv_heap_node *root);
 
@@ -138,7 +137,7 @@
                                                       *root);
 
 /**
- * Returns data stored at root of tree, doesn't affect anything
+ * Returns data stored at root of tree, doesn't effect anything
  */
 struct GNUNET_dv_neighbor *GNUNET_DV_Heap_peekRoot (struct GNUNET_dv_heap
                                                     *root);





reply via email to

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