Skip to main content

PeerRing

Struct PeerRing 

Source
pub struct PeerRing {
    pub did: Did,
    /* private fields */
}
Expand description

Chord routing and replicated-storage state for one network peer.

Fields§

§did: Did

The DID of the current node.

Implementations§

Source§

impl PeerRing

Source

pub fn holds_relay_mail(&self) -> bool

Whether this node holds relay mail: it keeps a retained relay store and has been online for the age gate (Law (Age gate), #777), so a node that leaves within its first minutes never pays a member’s copies.

Source

pub fn relay_custody(&self) -> RelayCustody

The relay custody this node declares when it connects.

Source§

impl PeerRing

Read-only views.

Source

pub fn successors(&self) -> SuccessorSeq

Return the successor sequence.

Source

pub const fn network_id(&self) -> u32

The overlay this ring belongs to; every stored value is admitted inside it.

Source§

impl PeerRing

Construction.

Source

pub fn new_with_storage( did: Did, succ_max: u8, storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>, ) -> PeerRing

Construct a peer ring with caller-provided entry storage.

Source

pub fn new_with_storage_and_finger_table_size( did: Did, succ_max: u8, storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>, finger_table_size: usize, ) -> PeerRing

Construct a peer ring with caller-provided storage and finger-table size.

Did is 160-bit. Sizes above DEFAULT_FINGER_TABLE_SIZE are clamped by FingerTable::new; zero disables finger maintenance.

Source

pub fn new_with_storage_finger_table_size_and_virtual_nodes( did: Did, succ_max: u8, storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>, finger_table_size: usize, virtual_nodes: VirtualNodeConfig, ) -> PeerRing

Construct a peer ring with storage and virtual ownership configuration.

Source

pub fn with_clock(self, clock: Arc<dyn Clock>) -> PeerRing

Configure the epoch SharedClock capability read by this ring’s storage decisions.

Source

pub fn with_rng(self, rng: SharedRng) -> PeerRing

Configure the SharedRng capability used by this ring’s topology tokens and jitter.

Source

pub fn clock(&self) -> &Arc<dyn Clock> ⓘ

Return the epoch SharedClock capability bound to this ring.

Source

pub fn epoch_ms(&self) -> u128

Read the current Unix epoch timestamp in milliseconds from this ring’s SharedClock.

Source

pub fn rng(&self) -> &SharedRng

Return the SharedRng capability bound to this ring.

Source

pub fn with_relay_storage( self, storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>, ) -> PeerRing

This ring with storage as the store of its relay-inbox namespace (see Self::relay_storage): a retained store, or, in a test that chooses it by name, an in-memory one.

Source

pub fn with_removal_storage( self, storage: Box<dyn KvStorageInterface<RemovalRecord> + Sync + Send>, ) -> PeerRing

This ring with storage as the store of the data namespace’s remove sides (see Self::removal_storage): a retained store, which refuses and never evicts (#920).

Source

pub fn edges(&self) -> &Arc<SlotRoster> ⓘ

The connection slots of this node (see Self::edges).

Source

pub fn with_relay_replication(self, replication: RelayReplication) -> PeerRing

This ring replicating relay custody as replication says (#777).

Source§

impl PeerRing

This impl block contains no public items.

Transition core: snapshot → step → commit under topology_transition.

Every mutation of routing state goes through Self::transition. The other functions here are its lock, clock, snapshot, commit, and action-translation helpers.

Source§

impl PeerRing

Membership: admitting connected peers and removing unreachable ones.

Source

pub fn remove(&self, did: Did) -> Result<TopologyRemoval, Error>

Remove a node from finger, predecessor, and successor state.

Returns whether the node was referenced, decided under the transition lock on the state the removal was applied to.

Source§

impl PeerRing

This impl block contains no public items.

Finger convergence.

The pure lifecycle of a finger lookup lives in dht::finger::convergence; this block only supplies its effects: the monotonic clock, fresh request tokens, and the serialized commit. In order of occurrence:

  1. Self::begin_finger_revalidation marks the ranges whose proof must be refreshed.
  2. Self::advance_finger_convergence emits at most one lookup, owned by a fresh UUID.
  3. The lookup’s report is applied by Self::apply_fixed_finger when its successor is already connected, or parked by Self::defer_fixed_finger under an admission lease while transport connects it; a lease that cannot be honoured is released by Self::retire_finger_candidate.
  4. Self::cancel_finger_lookup charges a lookup that transport could not deliver as one failed attempt.

Every step compares the caller’s token with the token the model currently owns, so a late or replayed report never moves newer state.

Source§

impl PeerRing

The first half of the HMCC/Zave stabilize operation.

The second half, applying the successor’s report, enters only through the token-checked report path: a report changes topology exactly when it echoes the correlation token that this call issued.

Source

pub fn pre_stabilize(&self) -> Result<PeerRingAction, Error>

Query the successor head for its predecessor and successor list.

The returned action carries the correlation token the head’s report must echo.

Source§

impl PeerRing

This impl block contains no public items.

Stabilization rounds.

A round is correlated by a fresh UUID recorded against the successor head it was sent to; only an authenticated report from that head carrying that UUID may change topology. In order of occurrence:

  1. Self::begin_stabilization records (head, request_id) as Requested and returns the query action. While the head’s previous report is still being processed it records nothing and emits nothing.
  2. Self::claim_stabilization_report moves the token to Processing exactly once, so duplicate deliveries of one report cannot both spend its connection budget, and hands the caller a [StabilizationClaim] that releases the token when dropped.
  3. Self::advance_stabilization_connection_plan hands out at most one candidate per call, re-checking the token each time; churn revokes the remaining budget.
  4. Self::stabilize_reported_by applies the report and returns the follow-up actions; Self::cancel_stabilization releases the token.

The pure model clears the token whenever the head changes, so a report answered by a superseded head is stale by construction.

Source§

impl PeerRing

This impl block contains no public items.

Successor-list synchronization.

Each successor may have one outstanding successor-list query, owned by a (reporter, request_id) token in [topology::SuccessorSyncState]. A token is valid only while its reporter is still a successor: the transition core prunes departed reporters’ tokens when a commit changes the successor list, and each operation here reads the list under the same lock it uses to touch the tokens.

Source§

impl PeerRing

This impl block contains no public items.

Transition law: every read-modify-write of a slot (an operation, a join, an acknowledged removal, and the retirement a read performs) runs under its store’s transition, one at a time: the storage transition for replicated storage, the cache transition for the fetch cache. The two stores share no slot and no invariant, so each has its own lock, and no path holds both. The inbound actor and the stabilizer write the same slots concurrently (a hold arriving while the recipient drains its inbox, a hand-off joining while a repair pass reads, two fetch replies, or a reply and the writer’s own write, meeting in one cache slot), and a store itself only orders single puts, so without this serialization one of two interleaved read-modify-writes would overwrite the other and a held message, an observed reply or an observed write could be lost. The transition is held across the store’s own awaits and nothing else, so it never nests and never waits on the network.

Source§

impl PeerRing

Source

pub fn storage_virtual_nodes_enabled(&self) -> Result<bool, Error>

Return whether the storage virtual-node registry is enabled.

Source

pub fn storage_virtual_positions( &self, owner: Did, ) -> Result<Vec<VirtualNode>, Error>

Return virtual storage positions owned by owner.

Trait Implementations§

Source§

impl Chord<PeerRingAction> for PeerRing

Source§

fn fix_fingers(&self) -> Result<PeerRingAction, Error>

One repair pass: begin revalidation, then emit the first due lookup.

Source§

fn find_successor(&self, did: Did) -> Result<PeerRingAction, Error>

Ask DHT for the successor of Did. May return a remote action for the successor is recorded in another node.
Source§

fn notify(&self, did: Did) -> Result<Did, Error>

Notify the DHT that a node is its predecessor. According to the paper, this method should be called periodically. This method should return the predecessor after updating.
Source§

impl ChordStorageCache<PeerRingAction> for PeerRing

Source§

fn local_cache_put<'life0, 'async_trait>( &'life0 self, entry: Entry, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, PeerRing: 'async_trait,

Join a fetched entry into the cache: cache[k] ← cache[k] ⊔ entry (#864).

Pre: entry satisfies the same admission law as a replicated write, so a peer cannot pin a fetched value in the cache past the retention bound it could obtain in storage. Post: the cached carrier is the join of every live reply observed for its key since the key last became resident, with this node’s own writes applied (Self::local_cache_observe_write), so, within one residency, it does not depend on the order in which replicas answer; it is projected to its element horizon, as every stored value is. The read-join-write is one cache transition, so two concurrent replies cannot lose one side.

Source§

fn local_cache_observe_write<'life0, 'async_trait>( &'life0 self, op: EntryOperation, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, PeerRing: 'async_trait,

Observe this node’s own write op in the cache: cache[k] ← (cache[k] or ⊥).operate(op), the transition every owner applies (#982).

Pre: op is stamped, as the owners receive it; stamping is idempotent, so its dots are the ones every owner applies. Post: an overwrite or an extend leaves cache[k] ⊔ stamped(op), below every replica that has applied op (R.operate(op) = R ⊔ stamped(op)), so the cache still ascends in ⊑; a tombstone leaves covering removes at the dots of its values the cache holds, the dots this writer observed and asked to remove. An operation the admission law refuses, which no owner applies, and a relay inbox, which no lookup reads, are not observed.

Source§

fn local_cache_get<'life0, 'async_trait>( &'life0 self, entry_key: Did, ) -> Pin<Box<dyn Future<Output = Result<Option<Entry>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, PeerRing: 'async_trait,

Read a cached entry, as a lookup serves it.

Post: a cached carrier past its retention bound, held live only by an unstable remove or register, is served as absent, as a replica serves it: a cache entry that serves no element must not answer a fetch as a found, empty topic while the owners hold live data.

Source§

impl ChordStorageRepair<PeerRingAction> for PeerRing

Source§

fn republish_local_entries<'life0, 'async_trait>( &'life0 self, redundancy: u16, ) -> Pin<Box<dyn Future<Output = Result<PeerRingAction, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, PeerRing: 'async_trait,

Republish every live locally stored entry to its current affine owners. Read more
Source§

fn read_repair_entry<'life0, 'life1, 'async_trait>( &'life0 self, entry: Entry, introducer: Principal, misses: &'life1 [PlacementMiss], redundancy: u16, ) -> Pin<Box<dyn Future<Output = Result<PeerRingAction, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PeerRing: 'async_trait,

Copy a found entry only to placement keys observed missing during lookup. Read more
Source§

impl ChordStorageSync<PeerRingAction> for PeerRing

Source§

fn sync_entries_with_successor<'life0, 'async_trait>( &'life0 self, new_successor: Did, ) -> Pin<Box<dyn Future<Output = Result<PeerRingAction, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, PeerRing: 'async_trait,

When the successor of a node is updated, it needs to check if there are Entrys that are no longer between current node and new_successor, and copy them to the new successor.

Source§

fn acknowledge_synced_entries<'life0, 'life1, 'async_trait>( &'life0 self, acks: &'life1 [SyncedEntryAck], ) -> Pin<Box<dyn Future<Output = Result<PeerRingAction, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, PeerRing: 'async_trait,

Delete local entries whose placement keys and exact values were durably stored by the successor during sync. 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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
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> Same for T

Source§

type Output = T

Should always be Self
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