Documentation
¶
Overview ¶
Package single implements a single sequencer.
Index ¶
- Variables
- type BatchQueue
- func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) error
- func (bq *BatchQueue) Load(ctx context.Context) error
- func (bq *BatchQueue) Next(ctx context.Context) (*coresequencer.Batch, error)
- func (bq *BatchQueue) Prepend(ctx context.Context, batch coresequencer.Batch) error
- func (bq *BatchQueue) Size() int
- type Sequencer
- func (c *Sequencer) GetDAHeight() uint64
- func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
- func (c *Sequencer) SetDAHeight(height uint64)
- func (c *Sequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.SubmitBatchTxsRequest) (*coresequencer.SubmitBatchTxsResponse, error)
- func (c *Sequencer) VerifyBatch(ctx context.Context, req coresequencer.VerifyBatchRequest) (*coresequencer.VerifyBatchResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidId = errors.New("invalid chain id")
ErrInvalidId is returned when the chain id is invalid
var ErrQueueFull = errors.New("batch queue is full")
ErrQueueFull is returned when the batch queue has reached its maximum size
Functions ¶
This section is empty.
Types ¶
type BatchQueue ¶
type BatchQueue struct {
// contains filtered or unexported fields
}
BatchQueue implements a persistent queue for transaction batches
func NewBatchQueue ¶
func NewBatchQueue(db ds.Batching, prefix string, maxSize int) *BatchQueue
NewBatchQueue creates a new BatchQueue with the specified maximum size. If maxSize is 0, the queue will be unlimited.
func (*BatchQueue) AddBatch ¶
func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) error
AddBatch adds a new transaction to the queue and writes it to the WAL. Returns ErrQueueFull if the queue has reached its maximum size.
func (*BatchQueue) Load ¶
func (bq *BatchQueue) Load(ctx context.Context) error
Load reloads all batches from WAL file into the in-memory queue after a crash or restart
func (*BatchQueue) Next ¶
func (bq *BatchQueue) Next(ctx context.Context) (*coresequencer.Batch, error)
Next extracts a batch of transactions from the queue and marks it as processed in the WAL
func (*BatchQueue) Prepend ¶
func (bq *BatchQueue) Prepend(ctx context.Context, batch coresequencer.Batch) error
Prepend adds a batch to the front of the queue (before head position). This is used to return transactions that couldn't fit in the current batch. The batch is persisted to the DB to ensure durability in case of crashes.
NOTE: Prepend intentionally bypasses the maxQueueSize limit to ensure high-priority transactions can always be re-queued.
func (*BatchQueue) Size ¶
func (bq *BatchQueue) Size() int
Size returns the effective number of batches in the queue This method is primarily for testing and monitoring purposes
type Sequencer ¶
type Sequencer struct {
Id []byte
// contains filtered or unexported fields
}
Sequencer implements core sequencing interface
func NewSequencer ¶
func NewSequencer( logger zerolog.Logger, db ds.Batching, daClient block.FullDAClient, cfg config.Config, id []byte, maxQueueSize int, genesis genesis.Genesis, executor execution.Executor, ) (*Sequencer, error)
NewSequencer creates a new Single Sequencer
func (*Sequencer) GetDAHeight ¶
GetDAHeight returns the current DA height
func (*Sequencer) GetNextBatch ¶
func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextBatchRequest) (*coresequencer.GetNextBatchResponse, error)
GetNextBatch implements sequencing.Sequencer. It gets the next batch of transactions and fetch for forced included transactions.
func (*Sequencer) SetDAHeight ¶
SetDAHeight sets the current DA height for the sequencer This should be called when the sequencer needs to sync to a specific DA height
func (*Sequencer) SubmitBatchTxs ¶
func (c *Sequencer) SubmitBatchTxs(ctx context.Context, req coresequencer.SubmitBatchTxsRequest) (*coresequencer.SubmitBatchTxsResponse, error)
SubmitBatchTxs implements sequencing.Sequencer. It adds mempool transactions to a batch.
func (*Sequencer) VerifyBatch ¶
func (c *Sequencer) VerifyBatch(ctx context.Context, req coresequencer.VerifyBatchRequest) (*coresequencer.VerifyBatchResponse, error)
VerifyBatch implements sequencing.Sequencer.