[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10904 - gnunet/src/hostlist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10904 - gnunet/src/hostlist |
Date: |
Wed, 14 Apr 2010 14:12:13 +0200 |
Author: wachs
Date: 2010-04-14 14:12:13 +0200 (Wed, 14 Apr 2010)
New Revision: 10904
Modified:
gnunet/src/hostlist/hostlist-client.c
Log:
Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c 2010-04-14 08:44:41 UTC (rev
10903)
+++ gnunet/src/hostlist/hostlist-client.c 2010-04-14 12:12:13 UTC (rev
10904)
@@ -759,12 +759,24 @@
"Hostlist client recieved advertisement from '%s' containing URI
%s\n", GNUNET_i2s (peer), uri );
/* search in map for peer identity */
+ hostlist = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
+ hostlist = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
+ hostlist->peer = (*peer);
+ hostlist->hello_count = 0;
+ hostlist->hostlist_uri = GNUNET_malloc ( uri_size);
+ memcpy ( hostlist->hostlist_uri, &incoming[1], uri_size );
+ hostlist->time_creation = GNUNET_TIME_absolute_get();
+ hostlist->time_last_usage = GNUNET_TIME_absolute_get_zero();
+
GNUNET_HashCode * peer_ident_hash = (GNUNET_HashCode * ) &(peer->hashPubKey);
if ( GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains (hostlist_hashmap,
peer_ident_hash) )
{
if ( MAX_NUMBER_HOSTLISTS > GNUNET_CONTAINER_multihashmap_size
(hostlist_hashmap) )
{
/* Entries available, add hostlist to hashmap */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding peer '%s' to hashmap %s\n", GNUNET_i2s (peer), uri );
+ GNUNET_CONTAINER_multihashmap_put ( hostlist_hashmap, peer_ident_hash,
hostlist, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE );
}
else
{
@@ -778,16 +790,6 @@
/* update recieved date (vs using last download time to check
reachability)? */
}
- /* GNUNET_CONTAINER_multihashmap_contains( hostlist_hashmap, )*/
- /* if it is not existing in map, create new a hostlist */
- hostlist = GNUNET_malloc ( sizeof (struct GNUNET_Hostlist) );
- hostlist->peer = (*peer);
- hostlist->hello_count = 0;
- hostlist->hostlist_uri = GNUNET_malloc ( uri_size);
- memcpy ( hostlist->hostlist_uri, &incoming[1], uri_size );
- hostlist->time_creation = GNUNET_TIME_absolute_get();
- hostlist->time_last_usage = GNUNET_TIME_absolute_get_zero();
-
return GNUNET_YES;
}
@@ -866,6 +868,23 @@
return GNUNET_OK;
}
+
+static int iterate_hashmap(void *cls, const GNUNET_HashCode *key, void *value)
+{
+ /* add code to process hostlist entries */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ ("Now iterating over peer entry: %s\n"), GNUNET_i2s ( (const
struct GNUNET_PeerIdentity *) key));
+
+ /* Testing */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ ("Entry url: %s \n"), ((struct GNUNET_Hostlist *)
value)->hostlist_uri );
+
+ if ( NULL != value )
+ GNUNET_free ( value );
+
+ return GNUNET_YES;
+}
+
/**
* Method to load persistent hostlist file during hostlist client shutdown
* param c configuration to use
@@ -896,8 +915,14 @@
}
/* add code to write hostlists to file using bio */
- GNUNET_BIO_write_string ( wh, "DUMMY TEXT");
+ /* iterate over all entries in hashmap */
+ GNUNET_CONTAINER_multihashmap_iterate ( hostlist_hashmap,
+ &iterate_hashmap,
+ NULL );
+
+ GNUNET_BIO_write_string ( wh, "DUMMY TEXT" );
+
if ( GNUNET_OK != GNUNET_BIO_write_close ( wh ) )
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
("Error while closing file %s\n"),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10904 - gnunet/src/hostlist,
gnunet <=