txbuffer

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: AGPL-3.0, ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

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 uint32, hashAlgorithm gocrypto.Hash) (*TxBuffer, error)

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

func (*TxBuffer) Add

Add adds the given transaction to the transaction buffer. Returns an error if the transaction isn't valid, is already present in the TxBuffer, or TxBuffer is full.

func (*TxBuffer) Capacity

func (t *TxBuffer) Capacity() uint32

func (*TxBuffer) Close

func (t *TxBuffer) Close()

func (*TxBuffer) Count

func (t *TxBuffer) Count() uint32

Count returns the total number of transactions in the TxBuffer.

func (*TxBuffer) Process

func (t *TxBuffer) Process(ctx context.Context, wg *sync.WaitGroup, process TxHandler)

type TxHandler

type TxHandler func(tx txsystem.GenericTransaction) bool

TxHandler handles the transaction. Must return true if the transaction must be removed from the transaction buffer.

Jump to

Keyboard shortcuts

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