gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6173 - GNUnet/src/applications/fs/gap


From: gnunet
Subject: [GNUnet-SVN] r6173 - GNUnet/src/applications/fs/gap
Date: Wed, 6 Feb 2008 13:00:52 -0700 (MST)

Author: grothoff
Date: 2008-02-06 13:00:52 -0700 (Wed, 06 Feb 2008)
New Revision: 6173

Modified:
   GNUnet/src/applications/fs/gap/gap.c
   GNUnet/src/applications/fs/gap/plan.c
Log:
scorecalc

Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c        2008-02-06 19:41:23 UTC (rev 
6172)
+++ GNUnet/src/applications/fs/gap/gap.c        2008-02-06 20:00:52 UTC (rev 
6173)
@@ -354,6 +354,8 @@
   GNUNET_mutex_unlock (GNUNET_FS_lock);
   if (active == 0)
     return 0;
+  if (active * (tot / active) < tot)
+    return (unsigned int) (tot / active) + 1;
   return (unsigned int) (tot / active);
 }
 

Modified: GNUnet/src/applications/fs/gap/plan.c
===================================================================
--- GNUnet/src/applications/fs/gap/plan.c       2008-02-06 19:41:23 UTC (rev 
6172)
+++ GNUnet/src/applications/fs/gap/plan.c       2008-02-06 20:00:52 UTC (rev 
6173)
@@ -339,7 +339,7 @@
   unsigned int prio;
   unsigned int ttl;
   unsigned int allowable_prio;
-  int score;
+  long long score;
 
   rank = GNUNET_malloc (sizeof (struct PeerRankings));
   memset (rank, 0, sizeof (struct PeerRankings));
@@ -367,17 +367,19 @@
         significant the more recent the last
         response was */
       history_score
-       = ((1LL<<30) * history->response_count) / (history->request_count * 
(now - last));
+       = (MAX_GAP_DELAY * history->response_count) / (history->request_count * 
(now - last));
       if (history->response_count == 0)
-       history_score = - history->request_count;
+       history_score = - history->request_count * 
coreAPI->forAllConnectedNodes(NULL, NULL);
+      if (history_score > (1 << 30))
+       history_score = (1 << 30);
     }
   /* check query proximity */
   proximity_score = GNUNET_hash_distance_u32 (&rpc->request->queries[0], 
&identity->hashPubKey);
 
   /* generate score, ttl and priority */
-  prio = rpc->request->last_prio_used + 1; /* increase over time */
+  prio = rpc->request->last_prio_used + 
GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, 2); /* increase over time */
   if (prio < history->last_good_prio)
-    prio = history->last_good_prio - 1; /* fall over time */
+    prio = history->last_good_prio - 
GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, 2); /* fall over time */
   if (prio > 1)
     {
       allowable_prio = GNUNET_FS_GAP_get_average_priority() + 1;
@@ -387,7 +389,7 @@
   ttl = rpc->request->last_ttl_used;
   if (prio > 0)
     {
-      ttl = 1 << 30; /* bound only by prio */
+      ttl = (1 << 30); /* bound only by prio */
     }
   else
     {
@@ -405,11 +407,19 @@
   rank->ttl = ttl;
 
   /* compute combined score */
-  score = 0; /* FIXME */
+  /* open question: any good weights for the scoring? */
+  score = history_score + rank->reserved_bandwidth - proximity_score;
   if (score <= - (1<<16))
-    rank->score = 1;
+    {
+      /* would underflow, use lowest legal score */
+      rank->score = 1;
+    }
   else
-    rank->score = (1<<16) + score;
+    {
+      rank->score = (unsigned int) ( (1<<16) + score);
+      if (rank->score < score) /* integer overflow */
+       rank->score = -1; /* max int */
+    }
 
   /* insert into ranking list */
   rank->next = rpc->rankings;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]