summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-03-11 23:34:46 -0500
committerNick Mathewson <nickm@torproject.org>2011-03-11 23:34:46 -0500
commitd52a99dc77dc77008b871da8bb2f95995d1abb6a (patch)
tree03d461c69b5d1468f162984d3da21dab8def889f /src/or/rephist.c
parent0b07b5dc989b50cb9fad82efe946f160713420cf (diff)
parentd34a5cdc597824e72453009ed209e5644f158e90 (diff)
downloadtor-d52a99dc77dc77008b871da8bb2f95995d1abb6a.tar.gz
tor-d52a99dc77dc77008b871da8bb2f95995d1abb6a.zip
Merge remote branch 'origin/maint-0.2.2'
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index be914227bb..2b804b1a1e 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -529,6 +529,20 @@ get_weighted_fractional_uptime(or_history_t *hist, time_t when)
return ((double) up) / total;
}
+/** Return how long the router whose identity digest is <b>id</b> has
+ * been reachable. Return 0 if the router is unknown or currently deemed
+ * unreachable. */
+long
+rep_hist_get_uptime(const char *id, time_t when)
+{
+ or_history_t *hist = get_or_history(id);
+ if (!hist)
+ return 0;
+ if (!hist->start_of_run || when < hist->start_of_run)
+ return 0;
+ return when - hist->start_of_run;
+}
+
/** Return an estimated MTBF for the router whose identity digest is
* <b>id</b>. Return 0 if the router is unknown. */
double