Skip to main content

SyncPlan

Struct SyncPlan 

Source
pub struct SyncPlan<E, S, V>
where E: Clock + Metrics + Storage, S: Scheme, V: Variant,
{ /* private fields */ }
Expand description

Startup plan that determines whether one-time peer state sync may still run.

Construction is two-phase so the caller can avoid fetching a finalized floor from peers when state sync has already completed:

  1. SyncPlan::init reads the durable state sync state.
  2. If SyncPlan::may_state_sync returns true, the caller fetches a finalized floor and attaches it via SyncPlan::with_floor. Otherwise the caller skips floor selection entirely.

The plan owns the opened metadata store and is later consumed by Stateful, so startup does not reopen the same metadata partition from multiple places.

Once state sync completes, this node never performs peer state sync again. Future startups must recover from the later of that synced height and marshal’s processed height instead.

Implementations§

Source§

impl<E, S, V> SyncPlan<E, S, V>
where E: Clock + Metrics + Storage, S: Scheme, V: Variant,

Source

pub async fn init(context: &E, partition_prefix: impl AsRef<str>) -> Self

Load the durable state sync metadata for this partition prefix.

§Panics

Panics if the metadata store cannot be opened. A node that cannot determine whether state sync already completed cannot safely choose a startup path.

Source

pub fn may_state_sync(&self) -> bool

Returns whether state sync can still run on this node.

When false, the caller should skip floor selection: any floor passed to SyncPlan::with_floor would be ignored. The node already has a durable completed state sync height, so future boots must recover from that height or marshal’s processed height instead of running peer state sync again.

When true, the caller can optionally attach a finalized floor via SyncPlan::with_floor. If a floor is not attached, the node will attempt to sync from genesis via marshal unless it is resuming an interrupted state sync.

Source

pub fn sync_height(&self) -> Option<Height>

Returns the durable completed state sync height, if one has been stored.

Source

pub const fn partition_prefix(&self) -> &str

Returns the partition prefix to use for state sync metadata storage.

Source

pub const fn floor(&self) -> Option<&Finalization<S, V::Commitment>>

Returns a reference to the finalized floor attached to this plan, if any.

Source

pub fn with_floor(self, floor: Finalization<S, V::Commitment>) -> Self

Attach a finalized floor to state sync from.

Has no effect if state sync has already completed.

Source

pub fn marshal_start<B>(&self, genesis: B) -> Start<S, V::Commitment, B>

Returns marshal’s startup anchor for this plan.

If a finalized floor was attached, marshal starts from that floor. Otherwise marshal starts from genesis and relies on its own durable progress to override that anchor when available.

Source

pub fn requires_state_sync_floor(&self) -> bool

Returns whether startup must attach a new state sync floor.

This is true after a previous process crashed while state sync was in progress. In that case Self::may_state_sync is also true, but starting from marshal/genesis is not allowed because partially synced database state must be reopened through the state-sync path.

Auto Trait Implementations§

§

impl<E, S, V> !Freeze for SyncPlan<E, S, V>

§

impl<E, S, V> !RefUnwindSafe for SyncPlan<E, S, V>

§

impl<E, S, V> Send for SyncPlan<E, S, V>

§

impl<E, S, V> Sync for SyncPlan<E, S, V>

§

impl<E, S, V> Unpin for SyncPlan<E, S, V>
where E: Unpin, <S as Scheme>::Certificate: Unpin, <V as Variant>::Commitment: Unpin, <E as Storage>::Blob: Unpin,

§

impl<E, S, V> UnsafeUnpin for SyncPlan<E, S, V>

§

impl<E, S, V> !UnwindSafe for SyncPlan<E, S, V>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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: 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: 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

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