optimize mqm_head scans by avoiding constantly scanning over definitively non-ready...
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new_paths.h
index 4b47784a05328002879fb05a4caaca975888596a..7310d75e640e0b72c47a0a06c5286dd75a9e9a3e 100644 (file)
 #include "gnunet-service-cadet-new.h"
 
 /**
- * Create a peer path based on the result of a DHT lookup.
- * If we already know this path, or one that is longer,
- * simply return NULL.
+ * Create a peer path based on the result of a DHT lookup.  If we
+ * already know this path, or one that is longer, simply return NULL.
+ * Otherwise, we try to extend an existing path, or create a new one
+ * if applicable.
  *
  * @param get_path path of the get request
  * @param get_path_length lenght of @a get_path
  * @param put_path path of the put request
  * @param put_path_length length of the @a put_path
- * @return a path through the network
  */
-struct CadetPeerPath *
-GCPP_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
-                    unsigned int get_path_length,
-                    const struct GNUNET_PeerIdentity *put_path,
-                    unsigned int put_path_length);
+void
+GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
+                        unsigned int get_path_length,
+                        const struct GNUNET_PeerIdentity *put_path,
+                        unsigned int put_path_length);
 
 
 /**
- * Destroy a path, we no longer need it.
+ * We got an incoming connection, obtain the corresponding path.
  *
- * @param path path to destroy.
+ * @param path_length number of segments on the @a path
+ * @param path through the network, in reverse order (we are at the end!)
+ * @return corresponding path object
  */
-void
-GCPP_path_destroy (struct CadetPeerPath *path);
+struct CadetPeerPath *
+GCPP_get_path_from_route (unsigned int path_length,
+                          const struct GNUNET_PeerIdentity *pids);
 
 
 /**
@@ -76,7 +79,7 @@ GCPP_get_length (struct CadetPeerPath *path);
  * @param path path to traverse
  * @param destination destination node to get to, must be on path
  * @param off offset of @a destination on @a path
- * @return NULL if @a create is NO and we have no existing connection
+ * @return NULL if we have no existing connection
  *         otherwise connection from us to @a destination via @a path
  */
 struct CadetConnection *
@@ -142,21 +145,6 @@ GNUNET_CONTAINER_HeapCostType
 GCPP_get_desirability (const struct CadetPeerPath *path);
 
 
-/**
- * The given peer @a cp used to own this @a path.  However, it is no
- * longer interested in maintaining it, so the path should be
- * discarded or shortened (in case a previous peer on the path finds
- * the path desirable).
- *
- * @param path the path that is being released
- * @param node entry in the heap of @a cp where this path is anchored
- *             should be used for updates to the desirability of this path
- */
-void
-GCPP_acquire (struct CadetPeerPath *path,
-              struct GNUNET_CONTAINER_HeapNode *node);
-
-
 /**
  * The given peer @a cp used to own this @a path.  However, it is no
  * longer interested in maintaining it, so the path should be
@@ -181,4 +169,14 @@ GCPP_get_peer_at_offset (struct CadetPeerPath *path,
                          unsigned int off);
 
 
+/**
+ * Convert a path to a human-readable string.
+ *
+ * @param path path to convert
+ * @return string, statically allocated
+ */
+const char *
+GCPP_2s (struct CadetPeerPath *p);
+
+
 #endif