[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8128 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8128 - GNUnet/src/applications/dv/module |
Date: |
Mon, 19 Jan 2009 12:40:54 -0700 (MST) |
Author: nevans
Date: 2009-01-19 12:40:54 -0700 (Mon, 19 Jan 2009)
New Revision: 8128
Modified:
GNUnet/src/applications/dv/module/dv.c
GNUnet/src/applications/dv/module/heap.c
GNUnet/src/applications/dv/module/heap.h
GNUnet/src/applications/dv/module/heaptest.c
Log:
pre-commit
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-01-19 19:24:41 UTC (rev
8127)
+++ GNUnet/src/applications/dv/module/dv.c 2009-01-19 19:40:54 UTC (rev
8128)
@@ -70,18 +70,20 @@
GNUNET_hash_to_enc (&neighbor->neighbor->hashPubKey, &encPeer);
if (neighbor->referrer == NULL)
- GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK, "%s\tNeighbor: %s\nCost: %d\n", type, (char
*) &encPeer,
- neighbor->cost);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "%s\tNeighbor: %s\nCost: %d\n", type,
+ (char *) &encPeer, neighbor->cost);
else
- {
- GNUNET_hash_to_enc (&neighbor->referrer->hashPubKey, &encReferrer);
- GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK, "%s\tNeighbor: %s\nCost: %d Referred by:
%s\n", type, (char *) &encPeer,
- neighbor->cost, (char*)&encReferrer);
- }
+ {
+ GNUNET_hash_to_enc (&neighbor->referrer->hashPubKey, &encReferrer);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "%s\tNeighbor: %s\nCost: %d Referred by: %s\n", type,
+ (char *) &encPeer, neighbor->cost,
+ (char *) &encReferrer);
+ }
return GNUNET_OK;
}
@@ -138,16 +140,19 @@
GNUNET_hash_to_enc (&peer->hashPubKey, &encPeer);
if (referrer == NULL)
- GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK, "Adding/Updating Node %s\n", (char *)
&encPeer);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "Adding/Updating Node %s\n",
+ (char *) &encPeer);
else
- {
- GNUNET_hash_to_enc (&referrer->hashPubKey, &encReferrer);
- GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK, "Adding/Updating Node %s, Learned about from
%s\n", (char *) &encPeer, (char *) &encReferrer);
- }
+ {
+ GNUNET_hash_to_enc (&referrer->hashPubKey, &encReferrer);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "Adding/Updating Node %s, Learned about from %s\n",
+ (char *) &encPeer, (char *) &encReferrer);
+ }
#endif
ret = GNUNET_OK;
@@ -267,8 +272,8 @@
GNUNET_GE_LOG (coreAPI->ectx,
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
GNUNET_GE_BULK,
- "Received info about peer %s from directly connected peer %s\n",
- (char *) &about, (char *) &from);
+ "Received info about peer %s from directly connected peer
%s\n",
+ (char *) &about, (char *) &from);
#endif
return ret;
}
@@ -333,25 +338,33 @@
*/
static int
delete_callback (struct GNUNET_dv_neighbor *neighbor,
- struct GNUNET_dv_heap *root, void * cls)
+ struct GNUNET_dv_heap *root, void *cls)
{
- GNUNET_PeerIdentity * toMatch = cls;
+ GNUNET_PeerIdentity *toMatch = cls;
#ifdef DEBUG_DV
- GNUNET_EncName encNeighbor;
- GNUNET_EncName encReferrer;
- GNUNET_EncName encToMatch;
+ GNUNET_EncName encNeighbor;
+ GNUNET_EncName encReferrer;
+ GNUNET_EncName encToMatch;
- GNUNET_hash_to_enc (&neighbor->neighbor->hashPubKey, &encNeighbor);
- GNUNET_hash_to_enc (&toMatch->hashPubKey, &encToMatch);
- if (neighbor->referrer != NULL)
- {
- GNUNET_hash_to_enc (&neighbor->referrer->hashPubKey,
&encReferrer);
- fprintf(stderr, "Checking for node\n%s to match\n%s or\n%s\n",
(char *)&encToMatch, (char *)&encNeighbor, (char *)&encReferrer);
- }
- fprintf(stderr, "Checking for node %s to match %s\n", (char
*)&encToMatch, (char *)&encNeighbor);
+ GNUNET_hash_to_enc (&neighbor->neighbor->hashPubKey, &encNeighbor);
+ GNUNET_hash_to_enc (&toMatch->hashPubKey, &encToMatch);
+ if (neighbor->referrer != NULL)
+ {
+ GNUNET_hash_to_enc (&neighbor->referrer->hashPubKey, &encReferrer);
+ fprintf (stderr, "Checking for node\n%s to match\n%s or\n%s\n",
+ (char *) &encToMatch, (char *) &encNeighbor,
+ (char *) &encReferrer);
+ }
+ fprintf (stderr, "Checking for node %s to match %s\n", (char *) &encToMatch,
+ (char *) &encNeighbor);
#endif
- if ((memcmp (neighbor->neighbor, toMatch, sizeof (GNUNET_PeerIdentity)) ==
0) || ((neighbor->referrer != NULL) && (memcmp (neighbor->referrer, toMatch,
sizeof (GNUNET_PeerIdentity)) == 0)))
+ if ((memcmp (neighbor->neighbor, toMatch, sizeof (GNUNET_PeerIdentity)) ==
+ 0) || ((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);
@@ -360,7 +373,7 @@
GNUNET_free (neighbor->neighbor);
if (neighbor->referrer != NULL)
- GNUNET_free (neighbor->referrer);
+ GNUNET_free (neighbor->referrer);
GNUNET_free (neighbor);
}
return GNUNET_OK;
@@ -404,7 +417,8 @@
&peer->hashPubKey);
GNUNET_DV_Heap_Iterator (&ctx->neighbor_max_heap,
- ctx->neighbor_max_heap.root,
&delete_callback, (void *)peer);
+ ctx->neighbor_max_heap.root,
+ &delete_callback, (void *) peer);
GNUNET_free (neighbor->neighbor);
if (neighbor->referrer)
@@ -445,7 +459,7 @@
GNUNET_GE_LOG (coreAPI->ectx,
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
GNUNET_GE_BULK, "Min heap size %d\nMax heap size %d\n",
- ctx->neighbor_min_heap.size, ctx->neighbor_max_heap.size);
+ ctx->neighbor_min_heap.size, ctx->neighbor_max_heap.size);
#endif
return GNUNET_DV_Heap_Walk_getNext (&ctx->neighbor_min_heap);
@@ -485,10 +499,10 @@
GNUNET_hash_to_enc (&about->neighbor->hashPubKey, &encPeerAbout);
GNUNET_hash_to_enc (&to->neighbor->hashPubKey, &encPeerTo);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK,
- "Sending info about peer %s to directly connected peer
%s\n",
- (char *) &encPeerAbout, (char *) &encPeerTo);
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+ | GNUNET_GE_BULK,
+ "Sending info about peer %s to directly connected
peer %s\n",
+ (char *) &encPeerAbout, (char *) &encPeerTo);
#endif
message->cost = htonl (about->cost);
memcpy (&message->neighbor, about->neighbor,
@@ -516,7 +530,7 @@
int ok = GNUNET_OK;
unsigned long long max_hosts;
- ctx = GNUNET_malloc(sizeof(struct GNUNET_DV_Context));
+ ctx = GNUNET_malloc (sizeof (struct GNUNET_DV_Context));
ctx->neighbor_min_heap.type = GNUNET_DV_MIN_HEAP;
ctx->neighbor_max_heap.type = GNUNET_DV_MAX_HEAP;
@@ -526,13 +540,13 @@
ctx->dvMutex = GNUNET_mutex_create (GNUNET_NO);
coreAPI = capi;
GNUNET_GE_LOG (capi->ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
_("`%s' registering P2P handler %d\n"),
"dv", GNUNET_P2P_PROTO_DV_NEIGHBOR_MESSAGE);
- GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
+ GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
"DV",
"FISHEYEDEPTH",
0, -1, 3, &ctx->fisheye_depth);
@@ -556,17 +570,17 @@
ctx->direct_neighbors = GNUNET_multi_hash_map_create (max_hosts);
- if (ctx->direct_neighbors == NULL)
- {
- ok = GNUNET_SYSERR;
- }
+ if (ctx->direct_neighbors == NULL)
+ {
+ ok = GNUNET_SYSERR;
+ }
- ctx->extended_neighbors =
- GNUNET_multi_hash_map_create (ctx->max_table_size * 3);
- if (ctx->extended_neighbors == NULL)
- {
- ok = GNUNET_SYSERR;
- }
+ ctx->extended_neighbors =
+ GNUNET_multi_hash_map_create (ctx->max_table_size * 3);
+ if (ctx->extended_neighbors == NULL)
+ {
+ ok = GNUNET_SYSERR;
+ }
if (GNUNET_SYSERR ==
coreAPI->peer_disconnect_notification_register
Modified: GNUnet/src/applications/dv/module/heap.c
===================================================================
--- GNUnet/src/applications/dv/module/heap.c 2009-01-19 19:24:41 UTC (rev
8127)
+++ GNUnet/src/applications/dv/module/heap.c 2009-01-19 19:40:54 UTC (rev
8128)
@@ -36,15 +36,15 @@
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);
- }
+ {
+ 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, "RIGHT of %d\n", root->neighbor->cost);
+ printTree (root->right_child);
+ }
}
static struct GNUNET_dv_heap_node *
@@ -221,7 +221,7 @@
struct GNUNET_dv_heap_node *del_node;
struct GNUNET_dv_heap_node *last;
- del_node = NULL;
+ del_node = NULL;
if (root->type == GNUNET_DV_MAX_HEAP)
del_node = neighbor->max_loc;
else if (root->type == GNUNET_DV_MIN_HEAP)
@@ -278,9 +278,9 @@
new_pos->neighbor = neighbor;
root->size++;
if (root->type == GNUNET_DV_MIN_HEAP)
- new_pos->neighbor->min_loc = new_pos;
+ new_pos->neighbor->min_loc = new_pos;
else if (root->type == GNUNET_DV_MAX_HEAP)
- new_pos->neighbor->max_loc = new_pos;
+ new_pos->neighbor->max_loc = new_pos;
percolateHeap (new_pos, root);
}
else
@@ -374,33 +374,35 @@
struct GNUNET_dv_heap_node *node,
GNUNET_PeerIdentity * toMatch)
{
- int count = 0;
+ int count = 0;
if (node->left_child != NULL)
{
- count += GNUNET_DV_Heap_delete_matching_referrers (root,
node->left_child,
- toMatch);
+ count +=
+ GNUNET_DV_Heap_delete_matching_referrers (root, node->left_child,
+ toMatch);
}
if (node->right_child != NULL)
{
- count += GNUNET_DV_Heap_delete_matching_referrers (root,
node->right_child,
- toMatch);
+ count +=
+ GNUNET_DV_Heap_delete_matching_referrers (root, node->right_child,
+ toMatch);
}
if ((node->neighbor != NULL)
&&
- (memcmp (node->neighbor, toMatch, sizeof (GNUNET_PeerIdentity))
- == 0))
+ (memcmp (node->neighbor, toMatch, sizeof (GNUNET_PeerIdentity)) == 0))
{
GNUNET_DV_Heap_removeNode (root, node->neighbor);
count++;
}
- return count;
+ return count;
}
void
-GNUNET_DV_Heap_Iterator (struct GNUNET_dv_heap *root,struct
GNUNET_dv_heap_node *node
-
,GNUNET_HeapIterator iterator,void *cls)
+GNUNET_DV_Heap_Iterator (struct GNUNET_dv_heap *root,
+ struct GNUNET_dv_heap_node *node,
+ GNUNET_HeapIterator iterator, void *cls)
{
if (node->left_child != NULL)
@@ -415,7 +417,7 @@
if (node->neighbor != NULL)
{
- iterator(node->neighbor, root, cls);
+ iterator (node->neighbor, root, cls);
}
}
@@ -438,12 +440,12 @@
choice = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1);
switch (choice)
- {
+ {
case 1:
- root->traversal_pos = root->traversal_pos->right_child;
+ root->traversal_pos = root->traversal_pos->right_child;
case 0:
- root->traversal_pos = root->traversal_pos->left_child;
- }
+ root->traversal_pos = root->traversal_pos->left_child;
+ }
return neighbor;
Modified: GNUnet/src/applications/dv/module/heap.h
===================================================================
--- GNUnet/src/applications/dv/module/heap.h 2009-01-19 19:24:41 UTC (rev
8127)
+++ GNUnet/src/applications/dv/module/heap.h 2009-01-19 19:40:54 UTC (rev
8128)
@@ -103,8 +103,8 @@
* iterate,
* GNUNET_NO if not.
*/
-typedef int (*GNUNET_HeapIterator) (struct GNUNET_dv_neighbor *neighbor,
- struct GNUNET_dv_heap *root, void *cls);
+typedef int (*GNUNET_HeapIterator) (struct GNUNET_dv_neighbor * neighbor,
+ struct GNUNET_dv_heap * root, void *cls);
/**
* Iterate over all entries in the map.
@@ -175,8 +175,7 @@
void
GNUNET_DV_Heap_Iterator (struct GNUNET_dv_heap *root,
struct GNUNET_dv_heap_node *node,
- GNUNET_HeapIterator iterator,
- void *cls);
+ GNUNET_HeapIterator iterator, void *cls);
/**
Modified: GNUnet/src/applications/dv/module/heaptest.c
===================================================================
--- GNUnet/src/applications/dv/module/heaptest.c 2009-01-19 19:24:41 UTC
(rev 8127)
+++ GNUnet/src/applications/dv/module/heaptest.c 2009-01-19 19:40:54 UTC
(rev 8128)
@@ -69,39 +69,39 @@
neighbor6->cost = 30;
GNUNET_DV_Heap_insert (myHeap, neighbor1);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_insert (myHeap, neighbor2);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_insert (myHeap, neighbor3);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_insert (myHeap, neighbor4);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_insert (myHeap, neighbor5);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_insert (myHeap, neighbor6);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_removeNode (myHeap, neighbor5);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_removeRoot (myHeap);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_updateCost (myHeap, neighbor6, 200);
- fprintf(stdout, "\n");
+ fprintf (stdout, "\n");
printTree (myHeap->root);
GNUNET_DV_Heap_Iterator (myHeap, myHeap->root, iterator_callback, NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8128 - GNUnet/src/applications/dv/module,
gnunet <=