txbuffer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxIsNil      = errors.New("tx is nil")
	ErrTxInBuffer   = errors.New("tx already in tx buffer")
	ErrTxBufferFull = errors.New("tx buffer is full")
)

Functions

This section is empty.

Types

type Observability

type Observability interface {
	Meter(name string, opts ...metric.MeterOption) metric.Meter
	Tracer(name string, options ...trace.TracerOption) trace.Tracer
	Logger() *slog.Logger
}

type TxBuffer

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

TxBuffer is an in-memory data structure containing the set of unconfirmed transactions.

func New

func New(maxSize uint, hashAlgorithm crypto.Hash, obs Observability) (*TxBuffer, error)

New creates a new instance of the TxBuffer. MaxSize specifies the total number of transactions the TxBuffer may contain.

func (*TxBuffer) Add

func (buf *TxBuffer) Add(ctx context.Context, tx *types.TransactionOrder) ([]byte, error)

Add adds the given transaction into the transaction buffer. Returns an error if the transaction is nil, is already present in the TxBuffer, or TxBuffer is full.

func (*TxBuffer) HashAlgorithm

func (buf *TxBuffer) HashAlgorithm() crypto.Hash

func (*TxBuffer) Remove

func (buf *TxBuffer) Remove(ctx context.Context) (*types.TransactionOrder, error)

Jump to

Keyboard shortcuts

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