pub struct SyncPlan<E, S, V>{ /* 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:
SyncPlan::initreads the durable state sync state.- If
SyncPlan::may_state_syncreturnstrue, the caller fetches a finalized floor and attaches it viaSyncPlan::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>
impl<E, S, V> SyncPlan<E, S, V>
Sourcepub async fn init(context: &E, partition_prefix: impl AsRef<str>) -> Self
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.
Sourcepub fn may_state_sync(&self) -> bool
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.
Sourcepub fn sync_height(&self) -> Option<Height>
pub fn sync_height(&self) -> Option<Height>
Returns the durable completed state sync height, if one has been stored.
Sourcepub const fn partition_prefix(&self) -> &str
pub const fn partition_prefix(&self) -> &str
Returns the partition prefix to use for state sync metadata storage.
Sourcepub const fn floor(&self) -> Option<&Finalization<S, V::Commitment>>
pub const fn floor(&self) -> Option<&Finalization<S, V::Commitment>>
Returns a reference to the finalized floor attached to this plan, if any.
Sourcepub fn with_floor(self, floor: Finalization<S, V::Commitment>) -> Self
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.
Sourcepub fn marshal_start<B>(&self, genesis: B) -> Start<S, V::Commitment, B>
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.
Sourcepub fn requires_state_sync_floor(&self) -> bool
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>where
E: UnsafeUnpin,
<S as Scheme>::Certificate: UnsafeUnpin,
<V as Variant>::Commitment: UnsafeUnpin,
<E as Storage>::Blob: UnsafeUnpin,
impl<E, S, V> !UnwindSafe for SyncPlan<E, S, V>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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