diff options
author | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2016-05-18 17:50:46 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-05-19 07:58:40 -0400 |
commit | 84ab26c320151bde1fc52906266126aa8d7780a3 (patch) | |
tree | bdb943887df1fb07fc49e21dde61572ddf7a815e /src/or/networkstatus.c | |
parent | 53aaed81dd34f227366b0a0c9b143c4c43a5529e (diff) | |
download | tor-84ab26c320151bde1fc52906266126aa8d7780a3.tar.gz tor-84ab26c320151bde1fc52906266126aa8d7780a3.zip |
Stop downloading consensuses when a consensus has been downloaded
Previosuly, during bootstrap, we would continue to download
consensuses if we had a consensus, but didn't have the certificates
to validate it.
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r-- | src/or/networkstatus.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index a9c8037e41..5e32003afb 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1247,16 +1247,30 @@ networkstatus_get_reasonably_live_consensus(time_t now, int flavor) return NULL; } -/** Check if we're bootstrapping a consensus download. This means that we are - * only using the authorities and fallback directory mirrors to download the - * consensus flavour we'll use. */ +/** Check if we need to download a consensus during tor's bootstrap phase. + * If we have no consensus, or our consensus is unusably old, return 1. + * As soon as we have received a consensus, return 0, even if we don't have + * enough certificates to validate it. */ int networkstatus_consensus_is_bootstrapping(time_t now) { - /* If we don't have a consensus, we must still be bootstrapping */ - return !networkstatus_get_reasonably_live_consensus( - now, - usable_consensus_flavor()); + /* If we have a validated, reasonably live consensus, we're not + * bootstrapping a consensus at all. */ + if (networkstatus_get_reasonably_live_consensus( + now, + usable_consensus_flavor())) { + return 0; + } + + /* If we have a consensus, but we're waiting for certificates, + * we're not waiting for a consensus download while bootstrapping. */ + if (consensus_is_waiting_for_certs()) { + return 0; + } + + /* If we have no consensus, or our consensus is very old, we are + * bootstrapping, and we need to download a consensus. */ + return 1; } /** Check if we can use multiple directories for a consensus download. |