Commit 502732d4 authored by Sebastian Stammler's avatar Sebastian Stammler

op-batcher: Improve code doc of channel builder & manager

parent 19834e00
...@@ -207,6 +207,9 @@ func (c *channelBuilder) closeAndOutputAllFrames() error { ...@@ -207,6 +207,9 @@ func (c *channelBuilder) closeAndOutputAllFrames() error {
} }
} }
// outputFrame creates one new frame and adds it to the frames queue.
// Note that compressed output data must be available on the underlying
// ChannelOut, or an empty frame will be produced.
func (c *channelBuilder) outputFrame() error { func (c *channelBuilder) outputFrame() error {
var buf bytes.Buffer var buf bytes.Buffer
fn, err := c.co.OutputFrame(&buf, c.cfg.MaxFrameSize) fn, err := c.co.OutputFrame(&buf, c.cfg.MaxFrameSize)
......
...@@ -183,9 +183,14 @@ func (s *channelManager) nextTxData() ([]byte, txID, error) { ...@@ -183,9 +183,14 @@ func (s *channelManager) nextTxData() ([]byte, txID, error) {
return data, id, nil return data, id, nil
} }
// TxData returns the next tx.data that should be submitted to L1. // TxData returns the next tx data that should be submitted to L1.
// It is very simple & currently ignores the l1Head provided (this will change). //
// It may buffer very large channels as well. // It currently only uses one frame per transaction. If the pending channel is
// full, it only returns the remaining frames of this channel until it got
// successfully fully sent to L1. It returns io.EOF if there's no pending frame.
//
// It currently ignores the l1Head provided and doesn't track channel timeouts
// or the sequencer window span yet.
func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) { func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) {
dataPending := s.pendingChannel != nil && s.pendingChannel.HasFrame() dataPending := s.pendingChannel != nil && s.pendingChannel.HasFrame()
s.log.Debug("Requested tx data", "l1Head", l1Head, "data_pending", dataPending, "blocks_pending", len(s.blocks)) s.log.Debug("Requested tx data", "l1Head", l1Head, "data_pending", dataPending, "blocks_pending", len(s.blocks))
...@@ -232,6 +237,8 @@ func (s *channelManager) ensurePendingChannel(l1Head eth.L1BlockRef) error { ...@@ -232,6 +237,8 @@ func (s *channelManager) ensurePendingChannel(l1Head eth.L1BlockRef) error {
return nil return nil
} }
// addBlocks adds blocks from the blocks queue to the pending channel until
// either the queue got exhausted or the channel is full.
func (s *channelManager) addBlocks() error { func (s *channelManager) addBlocks() error {
var ( var (
blockidx int blockidx int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment