Skip to main content

StateItem

Enum StateItem 

Source
pub enum StateItem {
    PendingVerification {
        channel_id: ChannelId,
        request: VerifyShareRequestMessage,
    },
    PendingRecovery {
        version: u32,
        shares: Vec<GetShareResponseMessage>,
    },
    PendingUnpair {
        channel_id: ChannelId,
        started_at: u64,
    },
    SharingRound {
        version: u32,
        pending: HashSet<ChannelId>,
        confirmed: HashSet<ChannelId>,
        failed: HashSet<ChannelId>,
        started_at: u64,
    },
}
Expand description

The payload of one row in the crate::protocol::DeRecStateStore.

§Write pattern

The library treats crate::protocol::DeRecStateStore::save as full-replacement upsert — there is no per-item merge or append semantic at the store level. Accumulator-style state (StateItem::PendingRecovery and StateItem::SharingRound) grows via load-modify-save cycles from the library. Backends do not need to implement any append primitive; a naive replace-on-save is correct.

Variants§

§

PendingVerification

The full outstanding derec_proto::VerifyShareRequestMessage the orchestrator sent for this channel. Retained so the corresponding inbound derec_proto::VerifyShareResponseMessage can be validated against the exact (nonce, secret_id, version) triple that was minted at request time.

Overwritten in place by a subsequent save for the same (secret_id, channel_id); the most recent challenge wins.

Fields

§channel_id: ChannelId
§

PendingRecovery

Accumulator for one in-progress recovery target.

The library writes this variant one share at a time as each inbound derec_proto::GetShareResponseMessage arrives. The write sequence under a single (secret_id, version) is:

  1. First response arrives. Library calls save with a shares vector containing exactly one element.
  2. Second response arrives. Library loads the accumulator, appends the new share to the returned Vec, and saves the grown Vec back.
  3. …repeat until threshold. On threshold met, library removes the accumulator.

Implementations MUST accept shares vectors of any length, including one. Every save replaces the stored value in place with the caller-supplied Vec; no append primitive is required.

§Concurrency

See crate::protocol::DeRecStateStore for the multi-instance concurrency contract. Concurrent inbound shares racing on the same accumulator will clobber each other via a naive load-modify-save; the application layer is responsible for serializing concurrent process() calls that touch the same (secret_id, version) if this matters.

Fields

§version: u32
§

PendingUnpair

Outstanding unpair acknowledgement window. started_at is the unix-seconds timestamp stamped when the request was sent; the orchestrator sweeps expired entries via crate::protocol::DeRecStateStore::load_all.

Fields

§channel_id: ChannelId
§started_at: u64
§

SharingRound

Active sharing round for secret_id. Created by start(ProtectSecret) and cleared by the orchestrator once every targeted helper has responded (confirmed, rejected, or timed out). At most one entry exists per secret_id; a fresh start(ProtectSecret) overwrites any prior in-flight round.

pending / confirmed / failed partition the round’s target channels; the union is invariant across the round’s lifetime. started_at is the unix-seconds timestamp used to time out unresponsive helpers.

Fields

§version: u32
§confirmed: HashSet<ChannelId>
§started_at: u64

Implementations§

Source§

impl StateItem

Source

pub fn kind(&self) -> StateKind

The StateKind this item is an instance of.

Source

pub fn key(&self) -> StateKey

The StateKey identifying this item within its (secret_id, kind) partition. Convenience so callers don’t have to hand-construct a key that matches the payload.

Trait Implementations§

Source§

impl Clone for StateItem

Source§

fn clone(&self) -> StateItem

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 Debug for StateItem

Source§

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

Formats the value using the given formatter. Read more

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<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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