mempool

package
v0.14.4-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTxnPoolFull  = errors.New("transaction pool is full")
	ErrTxnPoolEmpty = errors.New("transaction pool is empty")
)

Functions

This section is empty.

Types

type BroadcastedTransaction

type BroadcastedTransaction struct {
	Transaction   core.Transaction
	DeclaredClass core.Class
	PaidFeeOnL1   *felt.Felt
}

type Pool

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

Pool represents a blockchain mempool, managing transactions using both an in-memory and persistent database.

func New

func New(mainDB db.DB, bc blockchain.Reader, maxNumTxns int, log utils.SimpleLogger) *Pool

New initialises the Pool and starts the database writer goroutine. It is the responsibility of the caller to execute the closer function.

func (*Pool) Close added in v0.14.4

func (p *Pool) Close()

func (*Pool) Len

func (p *Pool) Len() int

Len returns the number of transactions in the in-memory pool

func (*Pool) LenDB

func (p *Pool) LenDB() (int, error)

Len returns the number of transactions in the persistent pool

func (*Pool) LoadFromDB

func (p *Pool) LoadFromDB() error

LoadFromDB restores the in-memory transaction pool from the database

func (*Pool) Pop

func (p *Pool) Pop() (BroadcastedTransaction, error)

Pop returns the transaction with the highest priority from the in-memory pool

func (*Pool) PopBatch added in v0.14.4

func (p *Pool) PopBatch(numToPop int) ([]BroadcastedTransaction, error)

PopBatch returns a batch of transactions with the highest priority from the in-memory pool

func (*Pool) Push

func (p *Pool) Push(userTxn *BroadcastedTransaction) error

Push queues a transaction to the pool

func (*Pool) Remove

func (p *Pool) Remove(hash ...*felt.Felt) error

Remove removes a set of transactions from the pool todo: should be called by the builder to remove txns from the db everytime a new block is stored. todo: in the consensus+p2p world, the txns should also be removed from the in-memory pool.

func (*Pool) Wait

func (p *Pool) Wait() <-chan struct{}

Jump to

Keyboard shortcuts

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