#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"
/**
* Preference update context
*/
- struct GNUNET_CORE_InformationRequestContext *info_ctx;
+ struct GNUNET_ATS_InformationRequestContext *info_ctx;
/**
* Task for scheduling preference updates
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;
+
/**
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);
}
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)
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,
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;
*/
#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"
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.
*/
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
* 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);
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++;
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);
}
* 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;
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))))
}
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)
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",
cp_map = NULL;
GNUNET_free (trustDirectory);
trustDirectory = NULL;
+ GNUNET_ATS_shutdown (ats);
+ ats = NULL;
}