txbuffer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 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

func (t *TxBuffer) Add(tx *types.TransactionOrder) ([]byte, error)

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, process TxHandler)

Process calls the "process" callback for a transaction. Return value of the callback should indicate whether the tx was processed successfully or not but currently this value is ignored - after callback returns the tx is always removed from internal buffer.

type TxHandler

type TxHandler func(ctx context.Context, tx *types.TransactionOrder) bool

TxHandler handles the transaction. Return value should indicate whether the tx was processed successfully (and thus removed from buffer) but currently this value is ignored - after callback returns the tx is always removed from internal buffer.

Jump to

Keyboard shortcuts

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