mempool

package
v0.14.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type BroadcastedTransaction

type BroadcastedTransaction struct {
	Transaction   core.Transaction
	DeclaredClass core.Class
}

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, state core.StateReader, maxNumTxns int, log utils.SimpleLogger) (*Pool, func() error)

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

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) 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