pub struct Timeouts {
pub inbound_message: Duration,
pub sharing_round: Duration,
pub unpair_ack: Duration,
pub get_share_response: Duration,
pub pairing: Duration,
pub expired_channels: ExpiredChannelCleanup,
}Expand description
How long the protocol waits on each thing it can be kept waiting by.
These were one knob until it became clear they answer different questions.
inbound_message is a security boundary — it
bounds how stale a message may be and still be accepted, so it has to
tolerate transport latency and clock skew. The other three are liveness
budgets: how long to keep hoping a peer will answer before giving up on it.
A value that suits one is wrong for the others, and collapsing them meant
tightening the replay window every time someone wanted rounds to settle
faster.
Unspecified fields keep their default:
use derec_library::protocol::types::Timeouts;
use std::time::Duration;
let timeouts = Timeouts {
sharing_round: Duration::from_secs(30),
..Default::default()
};
assert_eq!(timeouts.sharing_round, Duration::from_secs(30));
assert_eq!(timeouts.inbound_message, Duration::from_secs(300));§Granularity
One second is the smallest effective unit. Wire timestamps
(protobuf Timestamp.seconds) carry whole seconds only, so ages can be
measured no finer. Sub-second precision is truncated and any value below
one second is clamped to one, so an accidental Duration::ZERO cannot
silently disable a timeout.
Fields§
§inbound_message: DurationStaleness boundary for inbound envelopes: any message whose timestamp is older than this is discarded on receipt, whatever the flow. This is the replay-defence window.
Lower is not safer in any simple sense. The protocol is transport-agnostic — a store-and-forward transport, a phone that was offline, or a peer whose clock is a minute out all produce legitimately old messages, and this value is what decides whether they are refused.
Default: 300 seconds.
sharing_round: DurationHow long a publishing round waits for a peer that has not answered. On expiry the silent helpers are failed, the silent members are reported behind, and the round closes.
This is what bounds how long
DeRecEvent::SharingComplete
can be delayed by one unreachable peer, so it is the one to shorten if
a stalled round should surface quickly.
Default: 60 seconds.
unpair_ack: DurationHow long to wait for a peer to acknowledge an unpair before dropping the local channel state anyway. Expiry only discards local state; the unpair itself was already sent.
Default: 60 seconds.
How long a recovery waits for a Helper to answer its GetShareRequest.
A recovery decides only once every Helper it asked has answered or this has elapsed since the requests went out, so a secret is never chosen while an answer that could contradict it is still due. On expiry the silent Helpers are reported failed and the recovery settles on the shares it holds. The budget is a human one when Helpers approve share requests by hand.
The same budget bounds a replica version check
(DeRecFlow::ReplicaDiscovery):
once it elapses, the check concludes on the versions already reported.
Default: 300 seconds.
pairing: DurationHow long a pairing stays possible: how old a contact may be when it is scanned or answered, and how old a pairing request may be when it is accepted.
Both sides enforce it. The scanner refuses to start with a contact older than this. The creator ignores a request on such a contact, and neither prompts for nor accepts a request older than this, so a request accepted after its scanner gave up cannot leave a channel only one side holds. Nothing is sent on expiry: pairing involves both parties, and the remedy is to scan or share a fresh contact.
A scanner keeps its side of a pairing in flight for
expired_channels, which should therefore
be at least this plus the time a response takes to arrive.
The request’s age is measured against the creator’s clock and the contact’s age against the scanner’s, so two devices whose clocks differ by more than this cannot pair. The budget is also a human one: the contact must be scanned, and a manual accept given, within it.
Default: 30 seconds.
expired_channels: ExpiredChannelCleanupWhen to remove a channel still awaiting out-of-band fingerprint
confirmation — every replica pairing, and every
derec_proto::ContactMode::NoKeys pairing.
Unlike the others this can be ExpiredChannelCleanup::Disabled,
leaving the sweep to the application. The budget is a human one:
someone comparing a fingerprint out of band, possibly over the phone.
Shortening it below a minute or so will strand real pairings.
Default: Enabled { timeout_in_secs: 300 }.
Trait Implementations§
impl Copy for Timeouts
impl Eq for Timeouts
impl StructuralPartialEq for Timeouts
Auto Trait Implementations§
impl Forget for Timeouts
impl Freeze for Timeouts
impl Move for Timeouts
impl RefUnwindSafe for Timeouts
impl Send for Timeouts
impl Sync for Timeouts
impl Unpin for Timeouts
impl UnsafeUnpin for Timeouts
impl UnwindSafe for Timeouts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more