Expand description
Code implementing version 1 proof-of-work for onion service hosts.
Spec links:
Re-exportsΒ§
use std::collections::BTreeSet;πuse std::collections::HashMap;πuse std::collections::VecDeque;πuse std::sync::Arc;πuse std::sync::Mutex;πuse std::sync::RwLock;πuse std::task::Waker;πuse arrayvec::ArrayVec;πuse equix::EquiXBuilder;πuse futures::SinkExt;πuse futures::StreamExt;πuse futures::Stream;πuse futures::channel::mpsc;πuse num_traits::FromPrimitive;πuse rand::CryptoRng;πuse serde::Deserialize;πuse serde::Deserialize;πuse serde::Serialize;πuse serde::Serialize;πuse thiserror::Error;πuse tor_basic_utils::RngExt as _;πuse tor_cell::relaycell::hs::pow::ProofOfWork;πuse tor_cell::relaycell::hs::pow::v1::ProofOfWorkV1;πuse tor_checkable::timed::TimeRangeBound;πuse tor_error::warn_report;πuse tor_hscrypto::pk::HsBlindIdKey;πuse tor_hscrypto::pow::v1::Effort;πuse tor_hscrypto::pow::v1::Instance;πuse tor_hscrypto::pow::v1::RuntimeOption;πuse tor_hscrypto::pow::v1::Seed;πuse tor_hscrypto::pow::v1::SeedHead;πuse tor_hscrypto::pow::v1::Solution;πuse tor_hscrypto::pow::v1::SolutionErrorV1;πuse tor_hscrypto::pow::v1::Verifier;πuse tor_hscrypto::time::TimePeriod;πuse tor_keymgr::KeyMgr;πuse tor_netdir::NetDirProvider;πuse tor_netdir::NetdirProviderShutdown;πuse tor_netdir::params::NetParameters;πuse tor_netdoc::doc::hsdesc::pow::PowParams;πuse tor_netdoc::doc::hsdesc::pow::v1::PowParamsV1;πuse tor_persist::hsnickname::HsNickname;πuse tor_persist::state_dir::InstanceRawSubdir;πuse tor_persist::state_dir::StorageHandle;πuse tor_rtcompat::Runtime;πuse tor_rtcompat::SpawnExt;πuse web_time_compat::Duration;πuse web_time_compat::Instant;πuse web_time_compat::InstantExt;πuse web_time_compat::SystemTime;πuse web_time_compat::SystemTimeExt;πuse crate::BlindIdPublicKeySpecifier;πuse crate::OnionServiceConfig;πuse crate::RendRequest;πuse crate::ReplayError;πuse crate::StartupError;πuse crate::rend_handshake;πuse crate::replay::OpenReplayLogError;πuse crate::replay::PowNonceReplayLog;πuse crate::status::PowManagerStatusSender;πuse crate::status::Problem;πuse crate::status::State as PowManagerState;πuse super::NewPowManager;π
StructsΒ§
- PowManager
Generic π - This is responsible for rotating Proof-of-Work seeds and doing verification of PoW solves.
- PowManager
State πRecord - On-disk record of
PowManagerGenericstate. - Rend
Request πOrdBy Effort - Wrapper around
RendRequestthat implementsstd::cmp::Ordto sort byEffortand time. - Rend
Request πReceiver - Implements
Streamfor incomingRendRequests, using a priority queue system to dequeue high-Effortrequests first. - Rend
Request πReceiver Inner - Inner implementation for
RendRequestReceiver. - Seeds
ForTime πPeriod - Information about the current and previous
Seedfor a givenTimePeriod. - State π
- Internal state for
PowManagerGeneric.
EnumsΒ§
- PowError
- Error within the PoW subsystem.
- PowSolve
Error π - A PoW solve was invalid.
ConstantsΒ§
- EXPIRATION_
TIME_ πMINS_ MAX - Maximum seed expiration time in minutes. See: https://spec.torproject.org/hspow-spec/v1-equix.html#parameter-descriptor
- EXPIRATION_
TIME_ πMINS_ MIN - Minimum seed expiration time in minutes. See: https://spec.torproject.org/hspow-spec/v1-equix.html#parameter-descriptor
- HS_
UPDATE_ πPERIOD - How frequently the suggested effort should be recalculated.
- PUBLISHER_
UPDATE_ πQUEUE_ DEPTH - Depth of the queue used to signal the publisher that it needs to update a given time period.
- SEED_
EARLY_ πROTATION_ TIME - How soon before a seedβs expiration time we should rotate it and publish a new seed.
- SUGGESTED_
EFFORT_ πDEADZONE - When the suggested effort has changed by less than this much, we donβt republish it.
TraitsΒ§
- Mockable
PowManager π - Trait to allow mocking PowManagerGeneric in tests.
- Mockable
Rend πRequest - Trait to allow mocking RendRequest in tests.
Type AliasesΒ§
- PowManager π
- Proof-of-Work manager type alias for production, using concrete
RendRequest.