Rename fallback::status::Status to DirStatus.
It's about to be shared between fallbacks and guards.
This commit is contained in:
parent
314f5707b5
commit
75fd63a120
|
@ -3,13 +3,13 @@
|
|||
use std::time::{Duration, Instant};
|
||||
use tor_basic_utils::retry::RetryDelay;
|
||||
|
||||
/// Status information about whether a [`FallbackDir`](super::FallbackDir) is
|
||||
/// currently usable.
|
||||
/// Status information about whether a [`FallbackDir`](super::FallbackDir)
|
||||
/// is currently usable as a directory cache.
|
||||
///
|
||||
/// This structure is used to track whether the fallback cache has recently
|
||||
/// This structure is used to track whether the cache has recently
|
||||
/// failed, and if so, when it can be retried.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Status {
|
||||
pub(crate) struct DirStatus {
|
||||
/// Used to decide how long to delay before retrying a fallback cache
|
||||
/// that has failed.
|
||||
delay: RetryDelay,
|
||||
|
@ -24,16 +24,16 @@ pub(crate) struct Status {
|
|||
// TODO: we may want to make this configurable to a smaller value for chutney networks.
|
||||
const FALLBACK_RETRY_FLOOR: Duration = Duration::from_secs(150);
|
||||
|
||||
impl Default for Status {
|
||||
impl Default for DirStatus {
|
||||
fn default() -> Self {
|
||||
Status {
|
||||
DirStatus {
|
||||
delay: RetryDelay::from_duration(FALLBACK_RETRY_FLOOR),
|
||||
retry_at: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Status {
|
||||
impl DirStatus {
|
||||
/// Return true if this `Status` is usable at the time `now`.
|
||||
pub(crate) fn usable_at(&self, now: Instant) -> bool {
|
||||
match self.retry_at {
|
||||
|
@ -75,7 +75,7 @@ mod test {
|
|||
fn status_basics() {
|
||||
let now = Instant::now();
|
||||
|
||||
let mut status = Status::default();
|
||||
let mut status = DirStatus::default();
|
||||
// newly created status is usable.
|
||||
assert!(status.usable_at(now));
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
//! `tor-dirmgr`: any changes here must be reflected there.
|
||||
|
||||
mod set;
|
||||
mod status;
|
||||
|
||||
use crate::ids::FallbackId;
|
||||
use derive_builder::Builder;
|
||||
|
@ -22,9 +21,9 @@ use tor_llcrypto::pk::rsa::RsaIdentity;
|
|||
use serde::Deserialize;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use crate::dirstatus::DirStatus;
|
||||
pub use set::FallbackList;
|
||||
pub(crate) use set::FallbackState;
|
||||
use status::Status;
|
||||
|
||||
/// A directory whose location ships with Tor (or arti), and which we
|
||||
/// can use for bootstrapping when we don't know anything else about
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use rand::seq::IteratorRandom;
|
||||
use std::time::Instant;
|
||||
|
||||
use super::{FallbackDir, Status};
|
||||
use super::{DirStatus, FallbackDir};
|
||||
use crate::{ids::FallbackId, PickGuardError};
|
||||
use serde::Deserialize;
|
||||
|
||||
|
@ -67,13 +67,13 @@ pub(super) struct Entry {
|
|||
/// guard as well. Ought to fix that.)
|
||||
pub(super) fallback: crate::FirstHop,
|
||||
/// The status for the fallback directory.
|
||||
pub(super) status: Status,
|
||||
pub(super) status: DirStatus,
|
||||
}
|
||||
|
||||
impl From<FallbackDir> for Entry {
|
||||
fn from(fallback: FallbackDir) -> Self {
|
||||
let fallback = fallback.as_guard();
|
||||
let status = Status::default();
|
||||
let status = DirStatus::default();
|
||||
Entry { fallback, status }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ use tor_persist::{DynStorageHandle, StateMgr};
|
|||
use tor_rtcompat::Runtime;
|
||||
|
||||
mod daemon;
|
||||
mod dirstatus;
|
||||
mod err;
|
||||
pub mod fallback;
|
||||
mod filter;
|
||||
|
|
Loading…
Reference in New Issue