bqueue

package
v0.107.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheSize = 2000

DefaultCacheSize is the default amount of blocks above the current height which are stored in the queue.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockqueuer

type Blockqueuer interface {
	AddBlock(block *block.Block) error
	AddHeaders(...*block.Header) error
	BlockHeight() uint32
}

Blockqueuer is an interface for a block queue.

type OperationMode added in v0.107.0

type OperationMode byte

OperationMode is the mode of operation for the block queue. Could be either Blocking or NonBlocking.

const (
	// NonBlocking means that PutBlock will return immediately if the queue is full.
	NonBlocking OperationMode = 0
	// Blocking means that PutBlock will wait until there is enough space in the queue.
	Blocking OperationMode = 1
)

type Queue

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

Queue is the block queue.

func New

func New(bc Blockqueuer, log *zap.Logger, relayer func(*block.Block), cacheSize int, lenMetricsUpdater func(l int), mode OperationMode) *Queue

New creates an instance of BlockQueue.

func (*Queue) Discard

func (bq *Queue) Discard()

Discard stops the queue and prevents it from accepting more blocks to enqueue.

func (*Queue) LastQueued

func (bq *Queue) LastQueued() (uint32, int)

LastQueued returns the index of the last queued block and the queue's capacity left.

func (*Queue) PutBlock

func (bq *Queue) PutBlock(block *block.Block) error

PutBlock enqueues block to be added to the chain.

func (*Queue) Run

func (bq *Queue) Run()

Run runs the BlockQueue queueing loop. It must be called in a separate routine.

Jump to

Keyboard shortcuts

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