pub struct PeerRing {
pub did: Did,
/* private fields */
}Expand description
Chord routing and replicated-storage state for one network peer.
Fields§
§did: DidThe DID of the current node.
Implementations§
Source§impl PeerRing
impl PeerRing
Sourcepub fn holds_relay_mail(&self) -> bool
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.
Sourcepub fn relay_custody(&self) -> RelayCustody
pub fn relay_custody(&self) -> RelayCustody
The relay custody this node declares when it connects.
Source§impl PeerRing
Read-only views.
impl PeerRing
Read-only views.
Sourcepub fn successors(&self) -> SuccessorSeq
pub fn successors(&self) -> SuccessorSeq
Return the successor sequence.
Sourcepub const fn network_id(&self) -> u32
pub const fn network_id(&self) -> u32
The overlay this ring belongs to; every stored value is admitted inside it.
Source§impl PeerRing
Construction.
impl PeerRing
Construction.
Sourcepub fn new_with_storage(
did: Did,
succ_max: u8,
storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>,
) -> PeerRing
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> PeerRing
pub fn with_clock(self, clock: Arc<dyn Clock>) -> PeerRing
Configure the epoch SharedClock capability read by this ring’s storage decisions.
Sourcepub fn with_rng(self, rng: SharedRng) -> PeerRing
pub fn with_rng(self, rng: SharedRng) -> PeerRing
Configure the SharedRng capability used by this ring’s topology tokens and jitter.
Sourcepub fn clock(&self) -> &Arc<dyn Clock> ⓘ
pub fn clock(&self) -> &Arc<dyn Clock> ⓘ
Return the epoch SharedClock capability bound to this ring.
Sourcepub fn epoch_ms(&self) -> u128
pub fn epoch_ms(&self) -> u128
Read the current Unix epoch timestamp in milliseconds from this ring’s SharedClock.
Sourcepub fn with_relay_storage(
self,
storage: Box<dyn KvStorageInterface<Entry> + Sync + Send>,
) -> PeerRing
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.
Sourcepub fn with_removal_storage(
self,
storage: Box<dyn KvStorageInterface<RemovalRecord> + Sync + Send>,
) -> PeerRing
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).
Sourcepub fn edges(&self) -> &Arc<SlotRoster> ⓘ
pub fn edges(&self) -> &Arc<SlotRoster> ⓘ
The connection slots of this node (see Self::edges).
Sourcepub fn with_relay_replication(self, replication: RelayReplication) -> PeerRing
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.
impl PeerRing
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
This impl block contains no public items.Finger convergence.
impl PeerRing
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:
Self::begin_finger_revalidationmarks the ranges whose proof must be refreshed.Self::advance_finger_convergenceemits at most one lookup, owned by a fresh UUID.- The lookup’s report is applied by
Self::apply_fixed_fingerwhen its successor is already connected, or parked bySelf::defer_fixed_fingerunder an admission lease while transport connects it; a lease that cannot be honoured is released bySelf::retire_finger_candidate. Self::cancel_finger_lookupcharges 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.
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.
Sourcepub fn pre_stabilize(&self) -> Result<PeerRingAction, Error>
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.
impl PeerRing
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:
Self::begin_stabilizationrecords(head, request_id)asRequestedand returns the query action. While the head’s previous report is still being processed it records nothing and emits nothing.Self::claim_stabilization_reportmoves the token toProcessingexactly 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.Self::advance_stabilization_connection_planhands out at most one candidate per call, re-checking the token each time; churn revokes the remaining budget.Self::stabilize_reported_byapplies the report and returns the follow-up actions;Self::cancel_stabilizationreleases 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.
impl PeerRing
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.
impl PeerRing
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
impl PeerRing
Sourcepub fn storage_virtual_nodes_enabled(&self) -> Result<bool, Error>
pub fn storage_virtual_nodes_enabled(&self) -> Result<bool, Error>
Return whether the storage virtual-node registry is enabled.
Sourcepub fn storage_virtual_positions(
&self,
owner: Did,
) -> Result<Vec<VirtualNode>, Error>
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
impl Chord<PeerRingAction> for PeerRing
Source§fn fix_fingers(&self) -> Result<PeerRingAction, Error>
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>
fn find_successor(&self, did: Did) -> Result<PeerRingAction, Error>
Source§impl ChordStorageCache<PeerRingAction> for PeerRing
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,
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,
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,
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
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,
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,
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,
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,
Source§impl ChordStorageSync<PeerRingAction> for PeerRing
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,
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,
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,
Auto Trait Implementations§
impl !Freeze for PeerRing
impl !RefUnwindSafe for PeerRing
impl !UnwindSafe for PeerRing
impl Forget for PeerRing
impl Move for PeerRing
impl Send for PeerRing
impl Sync for PeerRing
impl Unpin for PeerRing
impl UnsafeUnpin for PeerRing
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.