summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2014-07-09 19:20:41 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2014-07-09 19:20:41 +0300
commitb74442db944be074785ce9590c34358959d7650a (patch)
tree1beb2813202ea69a80a1725d9a75f114c1ac583b /src/or
parenta8fcdbf4a0fcea3c97431f0c2bcc5a7774764ed4 (diff)
downloadtor-b74442db944be074785ce9590c34358959d7650a.tar.gz
tor-b74442db944be074785ce9590c34358959d7650a.zip
Change interface of router_descriptor_is_too_old().
Diffstat (limited to 'src/or')
-rw-r--r--src/or/routerlist.c11
-rw-r--r--src/or/routerlist.h3
2 files changed, 8 insertions, 6 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index bf4aff3b55..04d43e41e1 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3292,12 +3292,12 @@ routerlist_reset_warnings(void)
networkstatus_reset_warnings();
}
-/** Return 1 if the signed descriptor of this router is too old to be used.
- * Otherwise return 0. */
+/** Return 1 if the signed descriptor of this router is older than
+ * <b>seconds</b> seconds. Otherwise return 0. */
MOCK_IMPL(int,
-router_descriptor_is_too_old,(const routerinfo_t *router))
+router_descriptor_is_older_than,(const routerinfo_t *router, int seconds))
{
- return router->cache_info.published_on < time(NULL)-OLD_ROUTER_DESC_MAX_AGE;
+ return router->cache_info.published_on < time(NULL) - seconds;
}
/** Add <b>router</b> to the routerlist, if we don't already have it. Replace
@@ -3468,7 +3468,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
}
}
- if (!in_consensus && from_cache && router_descriptor_is_too_old(router)) {
+ if (!in_consensus && from_cache &&
+ router_descriptor_is_older_than(router, OLD_ROUTER_DESC_MAX_AGE)) {
*msg = "Router descriptor was really old.";
routerinfo_free(router);
return ROUTER_WAS_NOT_NEW;
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index adf5d32209..52f2303c7c 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -213,7 +213,8 @@ STATIC int choose_array_element_by_weight(const u64_dbl_t *entries,
STATIC void scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
uint64_t *total_out);
-MOCK_DECL(int, router_descriptor_is_too_old, (const routerinfo_t *router));
+MOCK_DECL(int, router_descriptor_is_older_than, (const routerinfo_t *router,
+ int seconds));
#endif
#endif