Author: grothoff Date: 2008-02-28 01:21:33 -0700 (Thu, 28 Feb 2008) New Revision: 6485
Modified: GNUnet/src/applications/fs/fsui/search.c GNUnet/src/applications/fs/gap/fs.c GNUnet/src/applications/fs/gap/gap.c GNUnet/src/applications/fs/gap/gap.h GNUnet/src/applications/fs/gap/plan.c GNUnet/src/applications/fs/gap/shared.h GNUnet/todo Log: adding trust award/earn/spent estimation code Modified: GNUnet/src/applications/fs/fsui/search.c =================================================================== --- GNUnet/src/applications/fs/fsui/search.c 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/fsui/search.c 2008-02-28 08:21:33 UTC (rev 6485) @@ -284,6 +284,7 @@ return GNUNET_SYSERR; } GNUNET_ECRS_search_stop (sl->handle); + sl->handle = NULL; sl->state = GNUNET_FSUI_PAUSED; event.type = GNUNET_FSUI_search_paused; event.data.SearchPaused.sc.pos = sl; Modified: GNUnet/src/applications/fs/gap/fs.c =================================================================== --- GNUnet/src/applications/fs/gap/fs.c 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/gap/fs.c 2008-02-28 08:21:33 UTC (rev 6485) @@ -662,6 +662,7 @@ coreAPI->preferTrafficFrom (sender, preference); GNUNET_FS_GAP_execute_query (sender, prio, + ntohl (req->priority), policy, ttl, type, Modified: GNUnet/src/applications/fs/gap/gap.c =================================================================== --- GNUnet/src/applications/fs/gap/gap.c 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/gap/gap.c 2008-02-28 08:21:33 UTC (rev 6485) @@ -82,7 +82,10 @@ static int stat_gap_content_found_locally; +static int stat_trust_earned; + + static unsigned int get_table_index (const GNUNET_HashCode * key) { @@ -197,6 +200,13 @@ req->have_more += HAVE_MORE_INCREMENT; want_more = GNUNET_SYSERR; } + if (stats != NULL) + { + stats->change(stat_trust_earned, + req->value_offered); + req->value_offered = 0; + } + req->remaining_value = 0; GNUNET_cron_add_job (cron, send_delayed, GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, @@ -215,6 +225,7 @@ * * @param respond_to where to send replies * @param priority how important is the request for us? + * @param original_priority how important is the request to the sender? * @param ttl how long should the query live? * @param type type of content requested * @param query_count how many queries are in the queries array? @@ -226,6 +237,7 @@ void GNUNET_FS_GAP_execute_query (const GNUNET_PeerIdentity * respond_to, unsigned int priority, + unsigned int original_priority, enum GNUNET_FS_RoutingPolicy policy, int ttl, unsigned int type, @@ -365,6 +377,7 @@ rl->type = type; rl->value = priority; rl->remaining_value = priority > 0 ? priority - 1 : 0; + rl->value_offered = original_priority; rl->expiration = newTTL; rl->next = table[index]; rl->response_target = peer; @@ -466,6 +479,12 @@ BASE_REPLY_PRIORITY * (1 + rl->value), MAX_GAP_DELAY); GNUNET_free (msg); + if (stats != NULL) + { + stats->change(stat_trust_earned, + rl->value_offered); + rl->value_offered = 0; + } if (rl->type != GNUNET_ECRS_BLOCKTYPE_DATA) GNUNET_FS_SHARED_mark_response_seen (rl, &hc); GNUNET_FS_PLAN_success (rid, NULL, rl->response_target, rl); @@ -656,6 +675,9 @@ stat_gap_query_refreshed = stats-> create (gettext_noop ("# gap queries refreshed existing record")); + stat_trust_earned = + stats-> + create (gettext_noop ("# trust earned")); } cron = GNUNET_cron_create (coreAPI->ectx); GNUNET_cron_start (cron); Modified: GNUnet/src/applications/fs/gap/gap.h =================================================================== --- GNUnet/src/applications/fs/gap/gap.h 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/gap/gap.h 2008-02-28 08:21:33 UTC (rev 6485) @@ -59,6 +59,7 @@ void GNUNET_FS_GAP_execute_query (const GNUNET_PeerIdentity * respond_to, unsigned int priority, + unsigned int original_priority, enum GNUNET_FS_RoutingPolicy policy, int ttl, unsigned int type, Modified: GNUnet/src/applications/fs/gap/plan.c =================================================================== --- GNUnet/src/applications/fs/gap/plan.c 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/gap/plan.c 2008-02-28 08:21:33 UTC (rev 6485) @@ -202,6 +202,8 @@ static int stat_gap_query_success; +static int stat_trust_spent; + /** * Find the entry in the client list corresponding * to the given client information. If no such entry @@ -686,7 +688,10 @@ } req->remaining_value -= prio; if (stats != NULL) - stats->change (stat_gap_query_sent, 1); + { + stats->change (stat_gap_query_sent, 1); + stats->change (stat_trust_spent, prio); + } return size; } @@ -965,6 +970,8 @@ stats->create (gettext_noop ("# gap content total planned")); stat_gap_query_success = stats->create (gettext_noop ("# gap routes succeeded")); + stat_trust_spent = + stats->create (gettext_noop ("# trust spent")); } return 0; } Modified: GNUnet/src/applications/fs/gap/shared.h =================================================================== --- GNUnet/src/applications/fs/gap/shared.h 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/src/applications/fs/gap/shared.h 2008-02-28 08:21:33 UTC (rev 6485) @@ -174,6 +174,12 @@ unsigned int value; /** + * Total offered value of the request (how much + * trust we will earn from the other peer). + */ + unsigned int value_offered; + + /** * Remaining value of the request (invalid * if response_client == NULL). */ Modified: GNUnet/todo =================================================================== --- GNUnet/todo 2008-02-28 07:09:09 UTC (rev 6484) +++ GNUnet/todo 2008-02-28 08:21:33 UTC (rev 6485) @@ -2,7 +2,6 @@ Annotations: RC == Release Critical - PRE == to be done before a pre-release 0.8.0pre0 [2'08]: - gnunet-gtk ready? _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn