l2

package
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository is responsible for storing and retrieving batches from the database If it can't find a batch it will request it from peers. It also subscribes for batch requests from peers and responds to them.

func NewBatchRepository

func NewBatchRepository(cfg *config.HostConfig, hostService batchRepoServiceLocator, storage storage.Storage, logger gethlog.Logger) *Repository

func (*Repository) AddBatch

func (r *Repository) AddBatch(batch *common.ExtBatch) error

AddBatch allows the host to add a batch to the repository, this is used: - when the node is a sequencer to store newly produced batches (the only way the sequencer host receives batches) - when the node is a validator to store batches read from roll-ups If the repository already has the batch it returns an AlreadyExists error which is typically ignored.

func (*Repository) FetchBatchBySeqNo

func (r *Repository) FetchBatchBySeqNo(seqNo *big.Int) (*common.ExtBatch, error)

func (*Repository) HandleBatchRequest

func (r *Repository) HandleBatchRequest(requesterID string, fromSeqNo *big.Int)

HandleBatchRequest handles a request for a batch from a peer, sending batches to the requester asynchronously todo (#1625) - only allow requests for batches since last rollup, to avoid DoS attacks.

func (*Repository) HandleBatches

func (r *Repository) HandleBatches(batches []*common.ExtBatch, isLive bool)

HandleBatches receives new batches from the p2p network, it also handles batches that are requested from peers If the batch is the new head of the L2 then it notifies subscribers to this service that a new batch has arrived

func (*Repository) HealthStatus

func (r *Repository) HealthStatus() host.HealthStatus

func (*Repository) Start

func (r *Repository) Start() error

func (*Repository) Stop

func (r *Repository) Stop() error

func (*Repository) Subscribe

func (r *Repository) Subscribe(handler host.L2BatchHandler) func()

Subscribe registers a handler to be notified of new head batches as they arrive, returns unsubscribe func

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL