diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-09-13 13:16:37 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-09-14 10:20:01 -0400 |
commit | c2c6d12a81bc46eaf2d017e4f9cd6f66cb145acb (patch) | |
tree | 053b4d9833232955031ee1ff98ba44c87c739ef8 /src/or/networkstatus.c | |
parent | 725d3a32bd025642a0b9ada0d2202508cbe9bbbe (diff) | |
download | tor-c2c6d12a81bc46eaf2d017e4f9cd6f66cb145acb.tar.gz tor-c2c6d12a81bc46eaf2d017e4f9cd6f66cb145acb.zip |
Move functions for seeing if we know enough nodes into nodelist
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index ff31f82ff6..0cc6a21085 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -2304,6 +2304,30 @@ networkstatus_parse_flavor_name(const char *flavname) return -1; } +/** Return 0 if this routerstatus is obsolete, too new, isn't + * running, or otherwise not a descriptor that we would make any + * use of even if we had it. Else return 1. */ +int +client_would_use_router(const routerstatus_t *rs, time_t now, + const or_options_t *options) +{ + if (!rs->is_flagged_running && !options->FetchUselessDescriptors) { + /* If we had this router descriptor, we wouldn't even bother using it. + * But, if we want to have a complete list, fetch it anyway. */ + return 0; + } + if (rs->published_on + options->TestingEstimatedDescriptorPropagationTime + > now) { + /* Most caches probably don't have this descriptor yet. */ + return 0; + } + if (rs->published_on + OLD_ROUTER_DESC_MAX_AGE < now) { + /* We'd drop it immediately for being too old. */ + return 0; + } + return 1; +} + /** If <b>question</b> is a string beginning with "ns/" in a format the * control interface expects for a GETINFO question, set *<b>answer</b> to a * newly-allocated string containing networkstatus lines for the appropriate |