pub struct BatchStore { /* private fields */ }
Expand description
A wrapper around a PersistentBatchStore.
Implementations§
source§impl BatchStore
impl BatchStore
sourcepub async fn new(
_ctx: &Ctx,
persistent: Box<dyn PersistentBatchStore>,
) -> Result<(Arc<Self>, BatchStoreRunner)>
pub async fn new( _ctx: &Ctx, persistent: Box<dyn PersistentBatchStore>, ) -> Result<(Arc<Self>, BatchStoreRunner)>
Constructs a BatchStore. BatchStore takes ownership of the passed PersistentBatchStore, i.e. caller should modify the underlying persistent storage ONLY through the constructed BatchStore.
sourcepub fn queued(&self) -> BatchStoreState
pub fn queued(&self) -> BatchStoreState
Available batches (in memory & persisted).
sourcepub async fn batch(
&self,
ctx: &Ctx,
number: BatchNumber,
) -> Result<Option<SyncBatch>>
pub async fn batch( &self, ctx: &Ctx, number: BatchNumber, ) -> Result<Option<SyncBatch>>
Fetches a batch (from queue or persistent storage).
sourcepub async fn queue_batch(
&self,
ctx: &Ctx,
batch: SyncBatch,
_genesis: Genesis,
) -> Result<()>
pub async fn queue_batch( &self, ctx: &Ctx, batch: SyncBatch, _genesis: Genesis, ) -> Result<()>
Append batch to a queue to be persisted eventually.
Since persisting a batch may take a significant amount of time,
BatchStore contains a queue of batches waiting to be persisted.
queue_batch()
adds a batch to the queue as soon as all intermediate
Batches are queued_state as well. Queue is unbounded, so it is caller’s
responsibility to manage the queue size.
sourcepub async fn wait_until_queued(
&self,
ctx: &Ctx,
number: BatchNumber,
) -> OrCanceled<BatchStoreState>
pub async fn wait_until_queued( &self, ctx: &Ctx, number: BatchNumber, ) -> OrCanceled<BatchStoreState>
Waits until the given batch is queued (in memory, or persisted). Note that it doesn’t mean that the batch is actually available, as old batches might get pruned.
sourcepub async fn wait_until_persisted(
&self,
ctx: &Ctx,
number: BatchNumber,
) -> OrCanceled<BatchStoreState>
pub async fn wait_until_persisted( &self, ctx: &Ctx, number: BatchNumber, ) -> OrCanceled<BatchStoreState>
Waits until the given batch is stored persistently. Note that it doesn’t mean that the batch is actually available, as old batches might get pruned.