[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8814 - GNUnet/src/applications/dv_dht/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8814 - GNUnet/src/applications/dv_dht/module |
Date: |
Thu, 30 Jul 2009 12:49:44 -0600 |
Author: nevans
Date: 2009-07-30 12:49:44 -0600 (Thu, 30 Jul 2009)
New Revision: 8814
Modified:
GNUnet/src/applications/dv_dht/module/routing.c
GNUnet/src/applications/dv_dht/module/table.h
Log:
reduce redundant routing of gets and replies
Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c 2009-07-30 18:49:09 UTC
(rev 8813)
+++ GNUnet/src/applications/dv_dht/module/routing.c 2009-07-30 18:49:44 UTC
(rev 8814)
@@ -198,16 +198,10 @@
DV_DHT_MESSAGE get;
/**
- * Hashcodes of the results that we have sent back
- * so far.
+ * Bloomfilter of the peers we've replied to so far
*/
- GNUNET_HashCode *results;
+ struct GNUNET_BloomFilter *bloom_results;
- /**
- * Number of entries in results.
- */
- unsigned int result_count;
-
} DV_DHTQueryRecord;
/*
@@ -495,6 +489,18 @@
continue;
}
+ match = GNUNET_NO;
+ match =
+ GNUNET_bloomfilter_test (q->bloom_results,
+ &pos->source.hashPubKey);
+ if (match == GNUNET_YES)
+ {
+ pos = pos->next;
+ continue;
+ }
+
+ GNUNET_bloomfilter_add (q->bloom_results,
+ &pos->source.hashPubKey);
GNUNET_bloomfilter_add (bloom, &pos->source.hashPubKey);
cost = dvapi->dv_send (&pos->source,
@@ -643,8 +649,8 @@
q->sources = pos->next;
GNUNET_free (pos);
}
- GNUNET_array_grow (q->results, q->result_count, 0);
}
+ GNUNET_bloomfilter_free (q->bloom_results);
GNUNET_multi_hash_map_remove_all (new_records.hashmap, &q->get.key);
}
@@ -671,6 +677,9 @@
else
{
q = GNUNET_malloc (sizeof (DV_DHTQueryRecord));
+ q->bloom_results =
+ GNUNET_bloomfilter_init (NULL, NULL, DV_DHT_BLOOM_SIZE,
+ DV_DHT_BLOOM_K);
q->sources = NULL;
}
@@ -738,7 +747,9 @@
{
GNUNET_PeerIdentity next[GET_TRIES + 1];
const DV_DHT_MESSAGE *get;
+ DV_DHTQueryRecord *q;
DV_DHT_MESSAGE aget;
+ DV_DHT_MESSAGE *oldget;
unsigned int target_value;
unsigned int hop_count;
struct GNUNET_BloomFilter *bloom;
@@ -761,6 +772,16 @@
GNUNET_DV_DHT_considerPeer (sender);
get = (const DV_DHT_MESSAGE *) msg;
+
+ if (GNUNET_multi_hash_map_contains (new_records.hashmap, &get->key))
+ {
+ q = GNUNET_multi_hash_map_get (new_records.hashmap, &get->key);
+ oldget = &q->get;
+ }
+ else
+ {
+ oldget = NULL;
+ }
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&get->key, &enc);
if (sender != NULL)
@@ -841,6 +862,8 @@
GNUNET_bloomfilter_init (NULL, &aget.bloomfilter[0], DV_DHT_BLOOM_SIZE,
DV_DHT_BLOOM_K);
GNUNET_bloomfilter_add (bloom, &coreAPI->my_identity->hashPubKey);
+ if (oldget != NULL)
+ GNUNET_bloomfilter_or (bloom, &oldget->bloomfilter[0], DV_DHT_BLOOM_SIZE);
GNUNET_bloomfilter_get_raw_data (bloom, &aget.bloomfilter[0],
DV_DHT_BLOOM_SIZE);
@@ -881,7 +904,7 @@
dvapi->dv_send (&next[j], &aget.header, DV_DHT_PRIORITY,
DV_DHT_DELAY);
- GNUNET_bloomfilter_add (bloom, &coreAPI->my_identity->hashPubKey);
+ GNUNET_bloomfilter_add (bloom, &next[j].hashPubKey);
if (cost == GNUNET_SYSERR)
continue;
@@ -1194,7 +1217,6 @@
q->sources = pos->next;
GNUNET_free (pos);
}
- GNUNET_array_grow (q->results, q->result_count, 0);
}
GNUNET_multi_hash_map_remove (new_records.hashmap, key, q);
GNUNET_CONTAINER_heap_remove_node (new_records.minHeap, q);
Modified: GNUnet/src/applications/dv_dht/module/table.h
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.h 2009-07-30 18:49:09 UTC
(rev 8813)
+++ GNUnet/src/applications/dv_dht/module/table.h 2009-07-30 18:49:44 UTC
(rev 8814)
@@ -82,6 +82,6 @@
/*
* Consider adding the peer to table
*/
-void GNUNET_DV_DHT_consider_peer (const GNUNET_PeerIdentity * peer);
+void GNUNET_DV_DHT_considerPeer (const GNUNET_PeerIdentity * peer);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8814 - GNUnet/src/applications/dv_dht/module,
gnunet <=