renaming in code to use new ATS pref/reservation API
authorChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 11:06:33 +0000 (11:06 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 11:06:33 +0000 (11:06 +0000)
src/dht/Makefile.am
src/dht/gnunet-service-dht_neighbours.c
src/fs/Makefile.am
src/fs/gnunet-service-fs_cp.c

index a88611fb3faa107e35e1b013f264d5ee66cf2c39..ba8b8457c6fe3e52e923df06e0e39ac8bff17c5f 100644 (file)
@@ -44,6 +44,7 @@ gnunet_service_dht_LDADD = \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/nse/libgnunetnse.la \
+  $(top_builddir)/src/ats/libgnunetats.la \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
   $(top_builddir)/src/hello/libgnunethello.la \
index 0623c0cb17fed0ff2b9196a5a5f48da7d5852a66..e1421e0f69b7224ac568aa9f5c1794e005c8bdc8 100644 (file)
@@ -32,6 +32,7 @@
 #include "gnunet_constants.h"
 #include "gnunet_protocols.h"
 #include "gnunet_nse_service.h"
+#include "gnunet_ats_service.h"
 #include "gnunet_core_service.h"
 #include "gnunet_datacache_lib.h"
 #include "gnunet_transport_service.h"
@@ -321,7 +322,7 @@ struct PeerInfo
   /**
    * Preference update context
    */
-  struct GNUNET_CORE_InformationRequestContext *info_ctx;
+  struct GNUNET_ATS_InformationRequestContext *info_ctx;
 
   /**
    * Task for scheduling preference updates
@@ -407,10 +408,15 @@ static GNUNET_SCHEDULER_TaskIdentifier find_peer_task;
 static struct GNUNET_PeerIdentity my_identity;
 
 /**
- * Handle to GNUnet core.
+ * Handle to CORE.
  */
 static struct GNUNET_CORE_Handle *coreAPI;
 
+/**
+ * Handle to ATS.
+ */
+static struct GNUNET_ATS_Handle *atsAPI;
+
 
 
 /**
@@ -514,10 +520,10 @@ update_core_preference (void *cls,
                            gettext_noop ("# Preference updates given to core"), 1,
                            GNUNET_NO);
   peer->info_ctx =
-    GNUNET_CORE_peer_change_preference (coreAPI, &peer->id,
-                                       0,
-                                       preference,
-                                       &update_core_preference_finish, peer);
+    GNUNET_ATS_peer_change_preference (atsAPI, &peer->id,
+                                      0,
+                                      preference,
+                                      &update_core_preference_finish, peer);
 }
 
 
@@ -725,7 +731,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
                                                        to_remove));
   if (NULL != to_remove->info_ctx)
   {
-    GNUNET_CORE_peer_change_preference_cancel (to_remove->info_ctx);
+    GNUNET_ATS_peer_change_preference_cancel (to_remove->info_ctx);
     to_remove->info_ctx = NULL;
   }
   if (GNUNET_SCHEDULER_NO_TASK != to_remove->preference_task)
@@ -2040,6 +2046,7 @@ GDS_NEIGHBOURS_init ()
       GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size",
                                              &temp_config_num))
     bucket_size = (unsigned int) temp_config_num;  
+  atsAPI = GNUNET_ATS_init (GDS_cfg, NULL, NULL);
   coreAPI = GNUNET_CORE_connect (GDS_cfg,
                                  1,
                                  NULL,
@@ -2067,6 +2074,8 @@ GDS_NEIGHBOURS_done ()
     return;
   GNUNET_CORE_disconnect (coreAPI);
   coreAPI = NULL;    
+  GNUNET_ATS_shutdown (atsAPI);
+  atsAPI = NULL;    
   GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers));
   GNUNET_CONTAINER_multihashmap_destroy (all_known_peers);
   all_known_peers = NULL;
index ae8d699a130ec4ebb097e9b30992efda77822545..85e3a4539a9c4484c8a4e89efd462772bbc24c29 100644 (file)
@@ -119,6 +119,7 @@ gnunet_service_fs_LDADD =  \
  $(top_builddir)/src/block/libgnunetblock.la \
  $(top_builddir)/src/datastore/libgnunetdatastore.la \
  $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/ats/libgnunetats.la \
  $(top_builddir)/src/core/libgnunetcore.la \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(GN_LIBINTL)
index ed855c42ec986b2b67695d7be0c8aa0fecc2bbae..05e5bedefa6e84d22e397010dce3c0286b1e023e 100644 (file)
@@ -25,6 +25,7 @@
  */
 #include "platform.h"
 #include "gnunet_load_lib.h"
+#include "gnunet_ats_service.h"
 #include "gnunet-service-fs.h"
 #include "gnunet-service-fs_cp.h"
 #include "gnunet-service-fs_pe.h"
@@ -240,9 +241,9 @@ struct GSF_ConnectedPeer
   struct GSF_PeerTransmitHandle *migration_pth;
 
   /**
-   * Context of our GNUNET_CORE_peer_change_preference call (or NULL).
+   * Context of our GNUNET_ATS_peer_change_preference call (or NULL).
    */
-  struct GNUNET_CORE_InformationRequestContext *irc;
+  struct GNUNET_ATS_InformationRequestContext *irc;
 
   /**
    * Task scheduled if we need to retry bandwidth reservation later.
@@ -301,6 +302,10 @@ static struct GNUNET_CONTAINER_MultiHashMap *cp_map;
  */
 static char *trustDirectory;
 
+/**
+ * Handle to ATS service.
+ */
+static struct GNUNET_ATS_Handle *ats;
 
 /**
  * Get the filename under which we would store the GNUNET_HELLO_Message
@@ -399,7 +404,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf);
  *        long should the client wait until re-trying?
  */
 static void
-core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
+ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
                        int32_t amount, struct GNUNET_TIME_Relative res_delay);
 
 
@@ -432,9 +437,9 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
     ip = cp->inc_preference;
     cp->inc_preference = 0;
     cp->irc =
-        GNUNET_CORE_peer_change_preference (GSF_core, &target,
-                                            DBLOCK_SIZE, ip,
-                                            &core_reserve_callback, cp);
+        GNUNET_ATS_peer_change_preference (ats, &target,
+                                          DBLOCK_SIZE, ip,
+                                          &ats_reserve_callback, cp);
   }
   GNUNET_assert (pth->cth == NULL);
   pth->cth_in_progress++;
@@ -518,9 +523,9 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   ip = cp->inc_preference;
   cp->inc_preference = 0;
   cp->irc =
-      GNUNET_CORE_peer_change_preference (GSF_core, &target,
-                                          DBLOCK_SIZE, ip,
-                                          &core_reserve_callback, cp);
+      GNUNET_ATS_peer_change_preference (ats, &target,
+                                        DBLOCK_SIZE, ip,
+                                        &ats_reserve_callback, cp);
 }
 
 
@@ -535,7 +540,7 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  *        long should the client wait until re-trying?
  */
 static void
-core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
+ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
                        int32_t amount, struct GNUNET_TIME_Relative res_delay)
 {
   struct GSF_ConnectedPeer *cp = cls;
@@ -584,9 +589,9 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
   cp->ppd.pid = GNUNET_PEER_intern (peer);
   cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
   cp->irc =
-      GNUNET_CORE_peer_change_preference (GSF_core, peer,
-                                          DBLOCK_SIZE, 0,
-                                          &core_reserve_callback, cp);
+      GNUNET_ATS_peer_change_preference (ats, peer,
+                                        DBLOCK_SIZE, 0,
+                                        &ats_reserve_callback, cp);
   fn = get_trust_filename (peer);
   if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) &&
       (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust))))
@@ -1551,7 +1556,7 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer)
   }
   if (NULL != cp->irc)
   {
-    GNUNET_CORE_peer_change_preference_cancel (cp->irc);
+    GNUNET_ATS_peer_change_preference_cancel (cp->irc);
     cp->irc = NULL;
   }
   if (GNUNET_SCHEDULER_NO_TASK != cp->irc_delay_task)
@@ -1825,6 +1830,7 @@ void
 GSF_connected_peer_init_ ()
 {
   cp_map = GNUNET_CONTAINER_multihashmap_create (128);
+  ats = GNUNET_ATS_init (GSF_cfg, NULL, NULL);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",
                                                           "TRUST",
@@ -1863,6 +1869,8 @@ GSF_connected_peer_done_ ()
   cp_map = NULL;
   GNUNET_free (trustDirectory);
   trustDirectory = NULL;
+  GNUNET_ATS_shutdown (ats);
+  ats = NULL;
 }