Trait tor_circmgr::timeouts::TimeoutEstimator
source · pub(crate) trait TimeoutEstimator {
// Required methods
fn note_hop_completed(&mut self, hop: u8, delay: Duration, is_last: bool);
fn note_circ_timeout(&mut self, hop: u8, delay: Duration);
fn timeouts(&mut self, action: &Action) -> (Duration, Duration);
fn learning_timeouts(&self) -> bool;
fn update_params(&mut self, params: &NetParameters);
fn build_state(&mut self) -> Option<ParetoTimeoutState>;
}
Expand description
An object that calculates circuit timeout thresholds from the history of circuit build times.
Required Methods§
sourcefn note_hop_completed(&mut self, hop: u8, delay: Duration, is_last: bool)
fn note_hop_completed(&mut self, hop: u8, delay: Duration, is_last: bool)
Record that a given circuit hop has completed.
The hop
number is a zero-indexed value for which hop just completed.
The delay
value is the amount of time after we first launched the
circuit.
If this is the last hop of the circuit, then is_last
is true.
sourcefn note_circ_timeout(&mut self, hop: u8, delay: Duration)
fn note_circ_timeout(&mut self, hop: u8, delay: Duration)
Record that a circuit failed to complete because it took too long.
The hop
number is a the number of hops that were successfully
completed.
The delay
number is the amount of time after we first launched the
circuit.
sourcefn timeouts(&mut self, action: &Action) -> (Duration, Duration)
fn timeouts(&mut self, action: &Action) -> (Duration, Duration)
Return the current estimation for how long we should wait for a given
Action
to complete.
This function should return a 2-tuple of (timeout, abandon)
durations. After timeout
has elapsed since circuit launch,
the circuit should no longer be used, but we should still keep
building it in order see how long it takes. After abandon
has elapsed since circuit launch, the circuit should be
abandoned completely.
sourcefn learning_timeouts(&self) -> bool
fn learning_timeouts(&self) -> bool
Return true if we’re currently trying to learn more timeouts by launching testing circuits.
sourcefn update_params(&mut self, params: &NetParameters)
fn update_params(&mut self, params: &NetParameters)
Replace the network parameters used by this estimator (if any)
with ones derived from params
.
sourcefn build_state(&mut self) -> Option<ParetoTimeoutState>
fn build_state(&mut self) -> Option<ParetoTimeoutState>
Construct a new ParetoTimeoutState to represent the current state of this estimator, if it is possible to store the state to disk.
TODO: change the type used for the state.