*/
struct GNUNET_CORE_TransmitHandle *th;
- /**
- * Preference update context
- */
- struct GNUNET_ATS_InformationRequestContext *info_ctx;
-
/**
* Task for scheduling preference updates
*/
/**
* Handle to ATS.
*/
-static struct GNUNET_ATS_SchedulingHandle *atsAPI;
+static struct GNUNET_ATS_PerformanceHandle *atsAPI;
}
-/**
- * Let GNUnet core know that we like the given peer.
- *
- * @param cls the 'struct PeerInfo' of the peer
- * @param tc scheduler context.
- */
-static void
-update_core_preference (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-
-/**
- * Function called with statistics about the given peer.
- *
- * @param cls closure
- * @param peer identifies the peer
- * @param amount set to the amount that was actually reserved or unreserved;
- * either the full requested amount or zero (no partial reservations)
- * @param res_delay if the reservation could not be satisfied (amount was 0), how
- * long should the client wait until re-trying?
- */
-static void
-update_core_preference_finish (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount,
- struct GNUNET_TIME_Relative res_delay)
-{
- struct PeerInfo *peer_info = cls;
-
- peer_info->info_ctx = NULL;
- peer_info->preference_task
- = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
- &update_core_preference, peer_info);
-}
-
-
/**
* Let GNUnet core know that we like the given peer.
*
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Preference updates given to core"), 1,
GNUNET_NO);
- peer->info_ctx =
- GNUNET_ATS_peer_change_preference (atsAPI, &peer->id,
- 0,
- preference,
- &update_core_preference_finish, peer);
+ GNUNET_ATS_change_preference (atsAPI, &peer->id,
+ GNUNET_ATS_PREFERENCE_BANDWIDTH,
+ (double) preference,
+ GNUNET_ATS_PREFERENCE_END);
+ peer->preference_task
+ = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
+ &update_core_preference, peer);
+
+
}
GNUNET_CONTAINER_multihashmap_remove (all_known_peers,
&peer->hashPubKey,
to_remove));
- if (NULL != 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_SCHEDULER_cancel (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);
+ atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
coreAPI = GNUNET_CORE_connect (GDS_cfg,
1,
NULL,
return;
GNUNET_CORE_disconnect (coreAPI);
coreAPI = NULL;
- GNUNET_ATS_shutdown (atsAPI);
+ GNUNET_ATS_performance_done (atsAPI);
atsAPI = NULL;
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers));
GNUNET_CONTAINER_multihashmap_destroy (all_known_peers);
struct GSF_PeerTransmitHandle *migration_pth;
/**
- * Context of our GNUNET_ATS_peer_change_preference call (or NULL).
+ * Context of our GNUNET_ATS_reserve_bandwidth call (or NULL).
*/
- struct GNUNET_ATS_InformationRequestContext *irc;
+ struct GNUNET_ATS_ReservationContext *rc;
/**
* Task scheduled if we need to retry bandwidth reservation later.
*/
- GNUNET_SCHEDULER_TaskIdentifier irc_delay_task;
+ GNUNET_SCHEDULER_TaskIdentifier rc_delay_task;
/**
* Active requests from this neighbour, map of query to 'struct PeerRequest'.
/**
* Handle to ATS service.
*/
-static struct GNUNET_ATS_SchedulingHandle *ats;
+static struct GNUNET_ATS_PerformanceHandle *ats;
/**
* Get the filename under which we would store the GNUNET_HELLO_Message
{
struct GSF_ConnectedPeer *cp;
struct GNUNET_PeerIdentity target;
- uint64_t ip;
if ((NULL != pth->cth) || (0 != pth->cth_in_progress))
return; /* already done */
cp = pth->cp;
GNUNET_assert (0 != cp->ppd.pid);
GNUNET_PEER_resolve (cp->ppd.pid, &target);
+
+ if (0 != cp->inc_preference)
+ {
+ GNUNET_ATS_change_preference (ats,
+ &target,
+ GNUNET_ATS_PREFERENCE_BANDWIDTH,
+ (double) cp->inc_preference,
+ GNUNET_ATS_PREFERENCE_END);
+ cp->inc_preference = 0;
+ }
+
if ((GNUNET_YES == pth->is_query) && (GNUNET_YES != pth->was_reserved))
{
/* query, need reservation */
cp->did_reserve = GNUNET_NO;
/* reservation already done! */
pth->was_reserved = GNUNET_YES;
- ip = cp->inc_preference;
- cp->inc_preference = 0;
- cp->irc =
- GNUNET_ATS_peer_change_preference (ats, &target,
- DBLOCK_SIZE, ip,
- &ats_reserve_callback, cp);
+ cp->rc =
+ GNUNET_ATS_reserve_bandwidth (ats, &target,
+ DBLOCK_SIZE,
+ &ats_reserve_callback, cp);
}
GNUNET_assert (pth->cth == NULL);
pth->cth_in_progress++;
retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GSF_ConnectedPeer *cp = cls;
- uint64_t ip;
struct GNUNET_PeerIdentity target;
GNUNET_PEER_resolve (cp->ppd.pid, &target);
- cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK;
- ip = cp->inc_preference;
- cp->inc_preference = 0;
- cp->irc =
- GNUNET_ATS_peer_change_preference (ats, &target,
- DBLOCK_SIZE, ip,
- &ats_reserve_callback, cp);
+ cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ cp->rc =
+ GNUNET_ATS_reserve_bandwidth (ats, &target,
+ DBLOCK_SIZE,
+ &ats_reserve_callback, cp);
}
*/
static void
ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- int32_t amount, struct GNUNET_TIME_Relative res_delay)
+ int32_t amount, struct GNUNET_TIME_Relative res_delay)
{
struct GSF_ConnectedPeer *cp = cls;
struct GSF_PeerTransmitHandle *pth;
- cp->irc = NULL;
+ cp->rc = NULL;
if (0 == amount)
{
- cp->irc_delay_task =
+ cp->rc_delay_task =
GNUNET_SCHEDULER_add_delayed (res_delay, &retry_reservation, cp);
return;
}
cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer));
cp->ppd.pid = GNUNET_PEER_intern (peer);
cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
- cp->irc =
- GNUNET_ATS_peer_change_preference (ats, peer,
- DBLOCK_SIZE, 0,
- &ats_reserve_callback, cp);
+ cp->rc =
+ GNUNET_ATS_reserve_bandwidth (ats, peer,
+ DBLOCK_SIZE,
+ &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))))
GSF_peer_transmit_cancel_ (cp->migration_pth);
cp->migration_pth = NULL;
}
- if (NULL != cp->irc)
+ if (NULL != cp->rc)
{
- GNUNET_ATS_peer_change_preference_cancel (cp->irc);
- cp->irc = NULL;
+ GNUNET_ATS_reserve_bandwidth_cancel (cp->rc);
+ cp->rc = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != cp->irc_delay_task)
+ if (GNUNET_SCHEDULER_NO_TASK != cp->rc_delay_task)
{
- GNUNET_SCHEDULER_cancel (cp->irc_delay_task);
- cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (cp->rc_delay_task);
+ cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK;
}
GNUNET_CONTAINER_multihashmap_iterate (cp->request_map,
&cancel_pending_request, cp);
GSF_connected_peer_init_ ()
{
cp_map = GNUNET_CONTAINER_multihashmap_create (128);
- ats = GNUNET_ATS_init (GSF_cfg, NULL, NULL);
+ ats = GNUNET_ATS_performance_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);
+ GNUNET_ATS_performance_done (ats);
ats = NULL;
}