pub struct ChannelBank<P>{ /* private fields */ }
Expand description
ChannelBank is a stateful stage that does the following:
- Unmarshalls frames from L1 transaction data
- Applies those frames to a channel
- Attempts to read from the channel when it is ready
- Prunes channels (not frames) when the channel bank is too large.
Note: we prune before we ingest data.
As we switch between ingesting data & reading, the prune step occurs at an odd point
Specifically, the channel bank is not allowed to become too large between successive calls
to IngestData
. This means that we can do an ingest and then do a read while becoming too
large. ChannelBank buffers channel frames, and emits full channel data
Implementations§
Source§impl<P> ChannelBank<P>
impl<P> ChannelBank<P>
Sourcepub fn new(cfg: Arc<RollupConfig>, prev: P) -> Self
pub fn new(cfg: Arc<RollupConfig>, prev: P) -> Self
Create a new ChannelBank stage.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of the channel bank by accumulating over all channels.
Sourcepub fn prune(&mut self) -> PipelineResult<()>
pub fn prune(&mut self) -> PipelineResult<()>
Prunes the Channel bank, until it is below the max channel bank size. Prunes from the high-priority channel since it failed to be read.
Sourcepub fn ingest_frame(&mut self, frame: Frame) -> PipelineResult<()>
pub fn ingest_frame(&mut self, frame: Frame) -> PipelineResult<()>
Adds new L1 data to the channel bank. Should only be called after all data has been read.
Sourcepub fn read(&mut self) -> PipelineResult<Option<Bytes>>
pub fn read(&mut self) -> PipelineResult<Option<Bytes>>
Read the raw data of the first channel, if it’s timed-out or closed.
Returns an error if there is nothing new to read.
Trait Implementations§
Source§impl<P> ChannelReaderProvider for ChannelBank<P>
impl<P> ChannelReaderProvider for ChannelBank<P>
Source§fn next_data<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PipelineResult<Option<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_data<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PipelineResult<Option<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl<P> Debug for ChannelBank<P>
impl<P> Debug for ChannelBank<P>
Source§impl<P> OriginAdvancer for ChannelBank<P>
impl<P> OriginAdvancer for ChannelBank<P>
Source§fn advance_origin<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PipelineResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn advance_origin<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PipelineResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
advance_l1_block
.