helper
authorChristian Grothoff <christian@grothoff.org>
Tue, 27 Sep 2011 14:20:12 +0000 (14:20 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 27 Sep 2011 14:20:12 +0000 (14:20 +0000)
src/hello/hello.c
src/include/gnunet_dht_service_new.h
src/include/gnunet_hello_lib.h

index 501f057c82a4725ce179f9daf324fce0126fcca6..b53bf62bcaf3ca70ed287cbda6692ea859f096b1 100644 (file)
@@ -590,6 +590,7 @@ find_matching (void *cls, const char *tname,
   return GNUNET_OK;
 }
 
+
 /**
  * Test if two HELLO messages contain the same addresses.
  * If they only differ in expiration time, the lowest
@@ -629,4 +630,33 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
 }
 
 
+static int
+find_min_expire (void *cls, const char *tname,
+                struct GNUNET_TIME_Absolute expiration, const void *addr,
+                uint16_t addrlen)
+{
+  struct GNUNET_TIME_Absolute *min = cls;
+
+  *min = GNUNET_TIME_absolute_min (*min, expiration);
+  return GNUNET_OK;
+}
+
+
+/**
+ * When does the last address in the given HELLO expire?
+ *
+ * @param msg HELLO to inspect
+ * @return time the last address expires, 0 if there are no addresses in the HELLO
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg)
+{
+  struct GNUNET_TIME_Absolute ret;
+
+  ret.abs_value = 0;
+  GNUNET_HELLO_iterate_addresses (msg, GNUNET_NO, &find_min_expire, &ret);
+  return ret;
+}
+
+
 /* end of hello.c */
index e180ad554d35463aebca8d3ae35fecdbf2ff61c2..88cc390b0d959b3aec6c352c1cf35dcc89d19b81 100644 (file)
@@ -142,10 +142,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
  * @param cls closure
  * @param exp when will this value expire
  * @param key key of the result
- * @param get_path NULL-terminated array of pointers
- *                 to the peers on reverse GET path (or NULL if not recorded)
- * @param put_path NULL-terminated array of pointers
- *                 to the peers on the PUT path (or NULL if not recorded)
+ * @param get_path peers on reply path (or NULL if not recorded)
+ * @param get_path_length number of entries in get_path
+ * @param put_path peers on the PUT path (or NULL if not recorded)
+ * @param put_path_length number of entries in get_path
  * @param type type of the result
  * @param size number of bytes in data
  * @param data pointer to the result data
@@ -153,10 +153,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
 typedef void (*GNUNET_DHT_GetIterator) (void *cls,
                                         struct GNUNET_TIME_Absolute exp,
                                         const GNUNET_HashCode * key,
-                                        const struct GNUNET_PeerIdentity *
-                                        const *get_path,
-                                        const struct GNUNET_PeerIdentity *
-                                        const *put_path,
+                                        const struct GNUNET_PeerIdentity *get_path,
+                                       unsigned int get_path_length,
+                                        const struct GNUNET_PeerIdentity *put_path,
+                                       unsigned int put_path_length,
                                         enum GNUNET_BLOCK_Type type,
                                         size_t size, const void *data);
 
@@ -173,8 +173,6 @@ typedef void (*GNUNET_DHT_GetIterator) (void *cls,
  * @param desired_replication_level estimate of how many
                   nearest peers this request should reach
  * @param options routing options for this message
- * @param bf bloom filter associated with query (can be NULL)
- * @param bf_mutator mutation value for bf
  * @param xquery extended query data (can be NULL, depending on type)
  * @param xquery_size number of bytes in xquery
  * @param iter function to call on each result
@@ -188,8 +186,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
                       enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key,
                       uint32_t desired_replication_level,
                       enum GNUNET_DHT_RouteOption options,
-                      const struct GNUNET_CONTAINER_BloomFilter *bf,
-                      int32_t bf_mutator, const void *xquery,
+                      const void *xquery,
                       size_t xquery_size, GNUNET_DHT_GetIterator iter,
                       void *iter_cls);
 
index 0ec1be7d1233f8255685e9996fd2485d1df1b929..7f5e5fee0b2aa4a17c24c938ac4304bb523a5404 100644 (file)
@@ -160,6 +160,16 @@ typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, const char *tname,
                                              uint16_t addrlen);
 
 
+/**
+ * When does the last address in the given HELLO expire?
+ *
+ * @param msg HELLO to inspect
+ * @return time the last address expires, 0 if there are no addresses in the HELLO
+ */
+struct GNUNET_TIME_Absolute
+GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg);
+
+
 /**
  * Iterate over all of the addresses in the HELLO.
  *