Documentation ¶
Index ¶
- type Repository
- func (r *Repository) AddBatch(batch *common.ExtBatch) error
- func (r *Repository) FetchBatchBySeqNo(ctx context.Context, seqNo *big.Int) (*common.ExtBatch, error)
- func (r *Repository) HandleBatchRequest(requesterID string, fromSeqNo *big.Int)
- func (r *Repository) HandleBatches(batches []*common.ExtBatch, isLive bool)
- func (r *Repository) HealthStatus(context.Context) host.HealthStatus
- func (r *Repository) NotifyNewValidatedHead(batch *common.ExtBatch)
- func (r *Repository) Start() error
- func (r *Repository) Stop() error
- func (r *Repository) SubscribeNewBatches(handler host.L2BatchHandler) func()
- func (r *Repository) SubscribeValidatedBatches(handler host.L2BatchHandler) func()
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 *hostconfig.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 (*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(context.Context) host.HealthStatus
func (*Repository) NotifyNewValidatedHead ¶ added in v0.24.1
func (r *Repository) NotifyNewValidatedHead(batch *common.ExtBatch)
NotifyNewValidatedHead - called after an enclave validates a batch, to update the repo's validated head and notify subscribers
func (*Repository) Start ¶
func (r *Repository) Start() error
func (*Repository) Stop ¶
func (r *Repository) Stop() error
func (*Repository) SubscribeNewBatches ¶ added in v0.24.1
func (r *Repository) SubscribeNewBatches(handler host.L2BatchHandler) func()
SubscribeNewBatches registers a handler to be notified of new head batches as they arrive, returns unsubscribe func
func (*Repository) SubscribeValidatedBatches ¶ added in v0.24.1
func (r *Repository) SubscribeValidatedBatches(handler host.L2BatchHandler) func()