static struct PeerRelative defvalues;
-
/**
- * Preference client
+ * Preference client, information we keep track of per client.
*/
struct PreferenceClient
{
/**
- * Next in DLL
+ * Previous in DLL
*/
struct PreferenceClient *prev;
struct PreferenceClient *next;
/**
- * Client handle
+ * Head of peer list
*/
- void *client;
+ struct PreferencePeer *p_head;
/**
- * Array of sum of absolute preferences for this client
+ * Tail of peer list
*/
- double f_abs_sum[GNUNET_ATS_PreferenceCount];
+ struct PreferencePeer *p_tail;
/**
- * Array of sum of relative preferences for this client
+ * Client handle
*/
- double f_rel_sum[GNUNET_ATS_PreferenceCount];
+ struct GNUNET_SERVER_Client *client;
/**
- * Head of peer list
+ * Array of sum of absolute preferences for this client
*/
- struct PreferencePeer *p_head;
+ double f_abs_sum[GNUNET_ATS_PreferenceCount];
/**
- * Tail of peer list
+ * Array of sum of relative preferences for this client
*/
- struct PreferencePeer *p_tail;
+ double f_rel_sum[GNUNET_ATS_PreferenceCount];
};
/**
- * Preference peer
+ * Preference information per peer and client.
*/
struct PreferencePeer
{
/**
- * Next in DLL
+ * Next in DLL of preference entries for the same client.
*/
struct PreferencePeer *next;
/**
- * Previous in DLL
+ * Previous in DLL of preference entries for the same client.
*/
struct PreferencePeer *prev;
/**
- * Client
+ * Client that expressed this preferences.
*/
struct PreferenceClient *client;
/**
- * Peer id
+ * Peer identity for which the preference was expressed.
*/
struct GNUNET_PeerIdentity id;
*/
static struct PreferenceClient *pc_tail;
-
-
-static struct GNUNET_SCHEDULER_Task * aging_task;
+/**
+ * Handle for task we run periodically to age preferences over time.
+ */
+static struct GNUNET_SCHEDULER_Task *aging_task;
/**
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "%u clients have a total relative preference for peer `%s' `%s' of %.3f and for %s in total %.3f\n",
- peer_count, GNUNET_i2s (id),
- GNUNET_ATS_print_preference_type (kind),
- f_rel_total,
- GNUNET_ATS_print_preference_type (kind),
- f_rel_sum);
+ "%u clients have a total relative preference for peer `%s' `%s' of %.3f and for %s in total %.3f\n",
+ peer_count,
+ GNUNET_i2s (id),
+ GNUNET_ATS_print_preference_type (kind),
+ f_rel_total,
+ GNUNET_ATS_print_preference_type (kind),
+ f_rel_sum);
/* Find entry for the peer containing relative values in the hashmap */
if (NULL != rp)
}
+/**
+ * FIXME
+ */
static int
update_iterator (void *cls,
const struct GNUNET_PeerIdentity *key,
}
-
/**
* Recalculate preference for a specific ATS property
*
}
-
+/**
+ * FIXME.
+ *
+ */
static void
run_preference_update (struct PreferenceClient *c_cur,
struct PreferencePeer *p_cur,
}
-
-
/**
* Reduce absolute preferences since they got old
*
* @param tc context
*/
static void
-preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+preference_aging (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PreferencePeer *p;
struct PreferenceClient *cur_client;
- int i;
- int values_to_update;
+ unsigned int i;
+ unsigned int values_to_update;
double backup;
aging_task = NULL;
if (values_to_update > 0)
{
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Rescheduling aging task due to %u elements to age\n",
- values_to_update);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Rescheduling aging task due to %u elements to age\n",
+ values_to_update);
aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
- &preference_aging, NULL );
+ &preference_aging,
+ NULL);
}
else
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "No values to age left, not rescheduling aging task\n");
-
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No values to age left, not rescheduling aging task\n");
+ }
}
GAS_normalization_get_preferences_by_peer (void *cls,
const struct GNUNET_PeerIdentity *id)
{
- GNUNET_assert(NULL != preference_peers);
- GNUNET_assert(NULL != id);
-
struct PeerRelative *rp;
- if (NULL == (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, id)))
+
+ if (NULL ==
+ (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers,
+ id)))
{
return defvalues.f_rel;
}