Skip to main content

Timeouts

Struct Timeouts 

Source
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: Duration

Staleness 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: Duration

How 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: Duration

How 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.

§get_share_response: Duration

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: Duration

How 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: ExpiredChannelCleanup

When 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§

Source§

impl Clone for Timeouts

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Timeouts

Source§

impl Debug for Timeouts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Timeouts

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Timeouts

Source§

impl PartialEq for Timeouts

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Timeouts

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V