summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-08 16:58:59 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-08 16:58:59 +0000
commite0b9c893bc4e60cb3e6d8aa65d49a2a4ba2b6260 (patch)
tree5394c35c788ee05f37bfb75fc5feca7c12dbd11a /src/or/rephist.c
parent46273c908020144d683365b956bfa9950b815296 (diff)
downloadtor-e0b9c893bc4e60cb3e6d8aa65d49a2a4ba2b6260.tar.gz
tor-e0b9c893bc4e60cb3e6d8aa65d49a2a4ba2b6260.zip
r16573@catbus: nickm | 2007-11-08 11:57:16 -0500
Mess with the formula for the Guard flag again. Now it requires that you be in the most familiar 7/8 of nodes, and have above median wfu for that 7/8th. See spec for details. Also, log thresholds better. svn:r12440
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 98d02d90d8..30c54fa473 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -384,8 +384,18 @@ get_stability(or_history_t *hist, time_t when)
return total / total_weights;
}
-/* Until we've known about you for this long, you simply can't be up. */
-#define MIN_WEIGHTED_TIME_TO_BE_UP (18*60*60)
+/** DODDOC */
+static long
+get_total_weighted_time(or_history_t *hist, time_t when)
+{
+ long total = hist->total_weighted_time;
+ if (hist->start_of_run) {
+ total += (when - hist->start_of_run);
+ } else if (hist->start_of_downtime) {
+ total += (when - hist->start_of_downtime);
+ }
+ return total;
+}
/** Helper: Return the weighted percent-of-time-online of the router with
* history <b>hist</b>. */
@@ -402,8 +412,6 @@ get_weighted_fractional_uptime(or_history_t *hist, time_t when)
} else if (hist->start_of_downtime) {
total += (when - hist->start_of_downtime);
}
- if (total < MIN_WEIGHTED_TIME_TO_BE_UP)
- return 0.0;
return ((double) up) / total;
}
@@ -431,6 +439,22 @@ rep_hist_get_weighted_fractional_uptime(const char *id, time_t when)
return get_weighted_fractional_uptime(hist, when);
}
+/** Return a number representing how long we've known about the router whose
+ * digest is <b>id</b>. Return 0 if the router is unknown.
+ *
+ * Be careful: this measure incresases monotonically as we know the router for
+ * longer and longer, but it doesn't increase linearly.
+ */
+long
+rep_hist_get_weighted_time_known(const char *id, time_t when)
+{
+ or_history_t *hist = get_or_history(id);
+ if (!hist)
+ return 0;
+
+ return get_total_weighted_time(hist, when);
+}
+
/** Return true if we've been measuring MTBFs for long enough to
* prounounce on Stability. */
int