pub trait SnapAttemptStore {
// Required methods
fn start_snap_attempt(
&self,
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>
where Self: MetadataWriter + HeaderProvider;
fn active_snap_write(&self) -> Result<Option<SnapWrite>, SnapSyncError>;
fn authorize_snap_write(
&self,
write: SnapWrite,
) -> Result<SnapAttempt, SnapSyncError>;
fn authorize_canonical_snap_write(
&self,
write: SnapWrite,
) -> Result<SnapAttempt, SnapSyncError>
where Self: BlockHashReader;
fn advance_snap_pivot(
&self,
write: SnapWrite,
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>
where Self: MetadataWriter + HeaderProvider + BlockHashReader;
fn verify_snap_attempt(&self, write: SnapWrite) -> Result<(), SnapSyncError>
where Self: MetadataWriter;
fn abandon_snap_attempt(&self) -> Result<(), SnapSyncError>
where Self: MetadataWriter;
fn snap_reorg(
&self,
write: SnapWrite,
) -> Result<Option<SnapReorg<<Self as HeaderProvider>::Header>>, SnapSyncError>
where Self: HeaderProvider + BlockHashReader;
fn commit_reorg_recovery(
&self,
write: SnapWrite,
ancestor: BlockNumHash,
lists: &[DecodedBal],
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>
where Self: MetadataWriter + HeaderProvider + BlockHashReader + DBProvider;
}Expand description
Persistence for the attempt that owns downloaded snap state.
Blanket-implemented over node metadata access, so these writes join the caller’s transaction: state, bytecode and the attempt record commit together or not at all.
Required Methods§
Sourcefn start_snap_attempt(
&self,
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>where
Self: MetadataWriter + HeaderProvider,
fn start_snap_attempt(
&self,
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>where
Self: MetadataWriter + HeaderProvider,
Starts an attempt anchored to generation, superseding any already recorded and the
progress it kept, with its catch-up progress at that pivot.
Sourcefn active_snap_write(&self) -> Result<Option<SnapWrite>, SnapSyncError>
fn active_snap_write(&self) -> Result<Option<SnapWrite>, SnapSyncError>
Returns the write an unfinished attempt accepts, if one owns the persisted state.
Returns the attempt when write still owns the persisted state, rejecting it otherwise.
Returns the attempt when write owns its state and its pivot is still canonical.
Downloaded ranges are proved against the pivot, so they describe the fork it sits on, not the canonical chain the applied blocks were checked against.
Sourcefn advance_snap_pivot(
&self,
write: SnapWrite,
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>
fn advance_snap_pivot( &self, write: SnapWrite, generation: SnapGeneration, ) -> Result<SnapWrite, SnapSyncError>
Re-anchors the attempt to generation, refusing writes proved against the previous root.
Both pivots must be canonical and the new one past the old, so it descends from all downloaded state. An orphaned pivot requires recovery or a fresh attempt.
Sourcefn verify_snap_attempt(&self, write: SnapWrite) -> Result<(), SnapSyncError>where
Self: MetadataWriter,
fn verify_snap_attempt(&self, write: SnapWrite) -> Result<(), SnapSyncError>where
Self: MetadataWriter,
Marks the attempt’s downloaded state verified.
Sourcefn abandon_snap_attempt(&self) -> Result<(), SnapSyncError>where
Self: MetadataWriter,
fn abandon_snap_attempt(&self) -> Result<(), SnapSyncError>where
Self: MetadataWriter,
Gives up on an unfinished attempt, refusing its outstanding writes.
Sourcefn snap_reorg(
&self,
write: SnapWrite,
) -> Result<Option<SnapReorg<<Self as HeaderProvider>::Header>>, SnapSyncError>where
Self: HeaderProvider + BlockHashReader,
fn snap_reorg(
&self,
write: SnapWrite,
) -> Result<Option<SnapReorg<<Self as HeaderProvider>::Header>>, SnapSyncError>where
Self: HeaderProvider + BlockHashReader,
Returns where the canonical chain diverges from the branch the pivot of write’s attempt
is on.
Ok(None) when the kept headers do not reach back to where the branches part.
Sourcefn commit_reorg_recovery(
&self,
write: SnapWrite,
ancestor: BlockNumHash,
lists: &[DecodedBal],
generation: SnapGeneration,
) -> Result<SnapWrite, SnapSyncError>
fn commit_reorg_recovery( &self, write: SnapWrite, ancestor: BlockNumHash, lists: &[DecodedBal], generation: SnapGeneration, ) -> Result<SnapWrite, SnapSyncError>
Schedules what lists, those of the orphaned blocks, changed in the downloaded state for
repair, and moves the attempt to generation with catch-up back at ancestor at most.
Storage persisted ahead of its range may hold the orphaned values, so it is dropped.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".