Skip to main content

MigrationContext

Struct MigrationContext 

Source
pub struct MigrationContext {
    pub p2p: Option<Arc<P2PNode>>,
    pub self_id: Option<PeerId>,
    pub self_xor: Option<XorName>,
    pub commitment: Option<Arc<ResponderCommitmentState>>,
    pub replication: Option<Arc<ReplicationConfig>>,
    pub sync_state: Option<Arc<RwLock<NeighborSyncState>>>,
    pub audit_challenge_coordinator: Option<Arc<AuditChallengeCoordinator>>,
    pub peer_commitments: Option<Arc<RwLock<HashMap<PeerId, PeerCommitmentRecord>>>>,
    pub close_group_size: usize,
}
Expand description

The network facts the driver needs, kept behind one type so the store itself stays free of any knowledge of routing or commitments.

Fields§

§p2p: Option<Arc<P2PNode>>

Routing, for close-group rank and possession checks. None in devnet and tests.

§self_id: Option<PeerId>

This node’s peer ID.

§self_xor: Option<XorName>

This node’s address in the key space, for ordering the copy closest-first.

§commitment: Option<Arc<ResponderCommitmentState>>

The responder commitment state, which owns the retention contract.

§replication: Option<Arc<ReplicationConfig>>

Replication settings, for the possession round that gates shedding.

§sync_state: Option<Arc<RwLock<NeighborSyncState>>>

Neighbour-sync state, which the possession challenge needs.

§audit_challenge_coordinator: Option<Arc<AuditChallengeCoordinator>>

Coordinator for the possession challenges.

§peer_commitments: Option<Arc<RwLock<HashMap<PeerId, PeerCommitmentRecord>>>>

What this node last heard each peer commit to.

Used to require that a peer trusted to hold a chunk is currently publishing a claim, rather than sitting between a retired commitment and its next rotation, which is precisely the state a node in the middle of its own migration is in.

§close_group_size: usize

Close-group width.

Implementations§

Source§

impl MigrationContext

Source

pub fn commitment_recipients_needed(&self) -> usize

How many peers of the close group must have seen the reduced commitment.

The same tolerance the pruner applies to possession proofs: all of them for a group of one or two, one short of the group otherwise, so a single unreachable peer cannot veto the migration forever without accepting an uninformed close group.

Source

pub async fn neighbours_know_the_commitment(&self) -> bool

Have enough of this node’s close group actually received its reduced commitment?

A rotation is not the same as neighbours knowing. Until they have seen the smaller key set they keep auditing against the one this node used to hold, so giving a chunk up before then turns a legitimate migration into a wave of audit failures.

Source

pub fn still_answerable(&self, key: &XorName) -> bool

Is this key still answerable under a retained commitment slot?

This is the pruner’s existing veto, reused verbatim: a key the node could still be challenged on must not lose its last local copy.

Source

pub fn shed_width(&self) -> usize

The width this node measures ranks against: the admission group, not the close group.

Source

pub async fn close_group_rank(&self, key: &XorName) -> GroupRank

This node’s position in key’s admission group.

Source

pub async fn may_shed(&self, key: &XorName) -> bool

May this node give up key without risking its last replica?

Only if it is outside the admission group entirely, or sits in that group’s last SHEDDABLE_TAIL_RANKS positions. Never when the answer is unknown.

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> 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, 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