Commit b107cff1 authored by Sebastian Stammler's avatar Sebastian Stammler

op-batcher: channelManager: Rename addBlocks -> processBlocks

and improve other code docs. It was confusing that AddL2Block adds a
block to the queue whereas addBlocks processed them, thereby removing
them from the queue. So renamed to `processBlocks`.
parent 72737362
...@@ -213,7 +213,7 @@ func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) { ...@@ -213,7 +213,7 @@ func (s *channelManager) TxData(l1Head eth.L1BlockRef) ([]byte, txID, error) {
s.triggerTimeout(l1Head) s.triggerTimeout(l1Head)
if err := s.addBlocks(); err != nil { if err := s.processBlocks(); err != nil {
return nil, txID{}, err return nil, txID{}, err
} }
...@@ -249,9 +249,9 @@ func (s *channelManager) triggerTimeout(l1Head eth.L1BlockRef) { ...@@ -249,9 +249,9 @@ func (s *channelManager) triggerTimeout(l1Head eth.L1BlockRef) {
) )
} }
// addBlocks adds blocks from the blocks queue to the pending channel until // processBlocks adds blocks from the blocks queue to the pending channel until
// either the queue got exhausted or the channel is full. // either the queue got exhausted or the channel is full.
func (s *channelManager) addBlocks() error { func (s *channelManager) processBlocks() error {
var blocksAdded int var blocksAdded int
var _chFullErr *ChannelFullError // throw away, just for type checking var _chFullErr *ChannelFullError // throw away, just for type checking
for i, block := range s.blocks { for i, block := range s.blocks {
...@@ -284,9 +284,9 @@ func (s *channelManager) addBlocks() error { ...@@ -284,9 +284,9 @@ func (s *channelManager) addBlocks() error {
return nil return nil
} }
// AddL2Block saves an L2 block to the internal state. It returns ErrReorg // AddL2Block adds an L2 block to the internal blocks queue. It returns ErrReorg
// if the block does not extend the last block loaded into the state. // if the block does not extend the last block loaded into the state. If no
// If no blocks were added yet, the parent hash check is skipped. // blocks were added yet, the parent hash check is skipped.
func (s *channelManager) AddL2Block(block *types.Block) error { func (s *channelManager) AddL2Block(block *types.Block) error {
if s.tip != (common.Hash{}) && s.tip != block.ParentHash() { if s.tip != (common.Hash{}) && s.tip != block.ParentHash() {
return ErrReorg return ErrReorg
......
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