Skip to main content

PointerState

Struct PointerState 

Source
pub struct PointerState {
    pub state_id: XorName,
    pub address: XorName,
    pub counter: u64,
    pub target: PointerTarget,
}
Expand description

The parts of a record that determine its authenticated state.

Parsed from the body alone, so obtaining one costs no signature verification. That is what lets a node recognise a re-submission of what it already holds and stop before doing expensive work.

Fields§

§state_id: XorName

The authenticated-state identifier, derived from the signed body.

§address: XorName

The address the record belongs at.

§counter: u64

The update counter, the merge rule’s first key.

§target: PointerTarget

The target, whose bytes are the merge rule’s second key.

Implementations§

Source§

impl PointerState

Source

pub fn parse(bytes: &[u8]) -> Result<Self, PointerError>

Parse the state out of a record’s bytes without verifying its signature.

Checks length, format version and structure only. A PointerState says what a record claims; only Pointer::from_bytes establishes that the claim is signed.

§Errors

Returns PointerError for a record of the wrong length, an unknown format version, or an unparseable owner key.

Source

pub const fn is_terminal(&self) -> bool

Whether this state is final: signed at FINAL_COUNTER, and so replaced by nothing.

Source

pub const fn transferred_to(&self) -> Option<XorName>

The pointer this state hands the address over to, if it is a transfer: a final state whose target is another pointer.

A final state targeting anything else freezes the pointer rather than handing it on, and a pointer target below the final counter is a forwarding the owner can still take back. Neither is a transfer.

Source

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

Whether self replaces other under the merge rule.

0. a final state (counter == u64::MAX) is replaced by nothing
1. larger counter
2. smaller target bytes

Records of different owners are not comparable and neither replaces the other.

Equal state never replaces, whatever the signature bytes: ML-DSA signing is randomized, so one authenticated state has unboundedly many valid encodings, and ordering records by their bytes would let an owner sign one paid state repeatedly, sort worst-first and have every submission win — unbounded storage, replication and audit work for a single payment.

Rule 0 is what makes a pointer’s last state final, and so what makes ownership transferable by redirection (Pointer::transfer_to). Under rules 1 and 2 alone a state at the final counter could still be displaced by another at the same counter with smaller target bytes, so a former owner could grind a target and take the address back after handing it on.

The cost is that the order is total only below the final counter. Two different final states are incomparable: neither replaces the other, so whichever a node took first is the one it keeps. That is the only conflict this rule leaves unordered, and so the only fork no later state heals; a conflict at a lower counter is ordered by target bytes and replaced by any later counter. Only the owner can make it — by signing a second final state and getting it to nodes the first has not reached, at once or later. Once a node holds a final state no arrival can change it, so a second final state can never displace an established one; it can only land on a node that held no final state. A reader tells the two sides apart by how many of the close group hold each.

Every other pair of distinct states is ordered, and the order is a strict partial order everywhere: never both ways round, and transitive.

Trait Implementations§

Source§

impl Clone for PointerState

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 PointerState

Source§

impl Debug for PointerState

Source§

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

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

impl Eq for PointerState

Source§

impl PartialEq for PointerState

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 PointerState

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Compare self to key and return true if they are equal.
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more