Don't pass NULL to destroy_route
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new_paths.c
index 05d702717f4dc218299d09647423e71bebf38e44..5bb658797a2177d7e35c695f535ff0e109b29252 100644 (file)
@@ -22,9 +22,6 @@
  * @brief Information we track per path.
  * @author Bartlomiej Polot
  * @author Christian Grothoff
- *
- * TODO:
- * - path desirability score calculations are not done
  */
 #include "platform.h"
 #include "gnunet-service-cadet-new_connection.h"
@@ -76,8 +73,16 @@ struct CadetPeerPath
 static void
 recalculate_path_desirability (struct CadetPeerPath *path)
 {
-  /* FIXME: update path desirability! */
-  GNUNET_break (0); // not implemented
+  double result = 0.0;
+
+  for (unsigned int i=0;i<path->entries_length;i++)
+  {
+    struct CadetPeer *cp = path->entries[i]->peer;
+
+    result += GCP_get_desirability_of_path (cp,
+                                            i);
+  }
+  path->desirability = (GNUNET_CONTAINER_HeapCostType) result;
 }