pub struct CheckpointManager { /* private fields */ }Expand description
Manages checkpoint reads/writes for an indexer.
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
pub fn new( store: Box<dyn CheckpointStore>, chain_id: impl Into<String>, indexer_id: impl Into<String>, save_interval: u64, ) -> Self
Sourcepub async fn load(&self) -> Result<Option<Checkpoint>, IndexerError>
pub async fn load(&self) -> Result<Option<Checkpoint>, IndexerError>
Load the saved checkpoint (returns None if none exists).
Sourcepub async fn maybe_save(
&mut self,
block_number: u64,
block_hash: &str,
) -> Result<(), IndexerError>
pub async fn maybe_save( &mut self, block_number: u64, block_hash: &str, ) -> Result<(), IndexerError>
Conditionally save a checkpoint every save_interval blocks.
Call this after each block is successfully processed.
Sourcepub async fn force_save(
&self,
block_number: u64,
block_hash: &str,
) -> Result<(), IndexerError>
pub async fn force_save( &self, block_number: u64, block_hash: &str, ) -> Result<(), IndexerError>
Immediately save a checkpoint (used on shutdown / reorg recovery).
Auto Trait Implementations§
impl Freeze for CheckpointManager
impl !RefUnwindSafe for CheckpointManager
impl Send for CheckpointManager
impl Sync for CheckpointManager
impl Unpin for CheckpointManager
impl UnsafeUnpin for CheckpointManager
impl !UnwindSafe for CheckpointManager
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
Mutably borrows from an owned value. Read more