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: XorNameThe authenticated-state identifier, derived from the signed body.
address: XorNameThe address the record belongs at.
counter: u64The update counter, the merge rule’s first key.
target: PointerTargetThe target, whose bytes are the merge rule’s second key.
Implementations§
Source§impl PointerState
impl PointerState
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, PointerError>
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.
Sourcepub const fn is_terminal(&self) -> bool
pub const fn is_terminal(&self) -> bool
Whether this state is final: signed at FINAL_COUNTER, and so
replaced by nothing.
Sourcepub const fn transferred_to(&self) -> Option<XorName>
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.
Sourcepub fn replaces(&self, other: &Self) -> bool
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 bytesRecords 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
impl Clone for PointerState
impl Copy for PointerState
Source§impl Debug for PointerState
impl Debug for PointerState
impl Eq for PointerState
Source§impl PartialEq for PointerState
impl PartialEq for PointerState
impl StructuralPartialEq for PointerState
Auto Trait Implementations§
impl Freeze for PointerState
impl RefUnwindSafe for PointerState
impl Send for PointerState
impl Sync for PointerState
impl Unpin for PointerState
impl UnsafeUnpin for PointerState
impl UnwindSafe for PointerState
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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