Commit 2e99c9fe authored by Nick Mathewson's avatar Nick Mathewson 🦞
Browse files

dirmgr: use set_skew_limit.

With this API we can now stop consensus download attempts early if
any consensus that the directory cache gave us would be necessarily
too far in the future or in the past.

This saves wasted bandwidth for clients with skewed clocks.

Closes #466.
parent 0c939d45
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -141,6 +141,15 @@ pub(crate) fn make_consensus_request(
        }
    }

    request.set_skew_limit(
        // If we are _fast_ by at least this much, then any valid directory will
        // seem to be at least this far in the past.
        config.tolerance.post_valid_tolerance,
        // If we are _slow_ by this much, then any valid directory will seem to
        // be at least this far in the future.
        config.tolerance.pre_valid_tolerance,
    );

    Ok(ClientRequest::Consensus(request))
}