mempool

package
v0.2.6-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TxMempool

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

TxMempool is a struct that holds txs received via gossip network.

func NewTxMemPool

func NewTxMemPool() *TxMempool

NewTxMemPool returns a new TxMempool struct.

func (*TxMempool) Get

Get returns transaction by provided id, it returns an error if transaction is not found.

func (*TxMempool) GetProjection

func (t *TxMempool) GetProjection(addr types.Address, prevNonce, prevBalance uint64) (nonce, balance uint64)

GetProjection returns the estimated nonce and balance for the provided address addr and previous nonce and balance projecting state is done by applying transactions from the pool.

func (*TxMempool) GetTxsByAddress

func (t *TxMempool) GetTxsByAddress(addr types.Address) []*types.Transaction

GetTxsByAddress returs all transactions from/to a specific address.

func (*TxMempool) GetTxsForBlock

func (t *TxMempool) GetTxsForBlock(numOfTxs int, getState func(addr types.Address) (nonce, balance uint64, err error)) ([]types.TransactionID, []*types.Transaction, error)

GetTxsForBlock gets a specific number of random txs for a block. This function also receives a state calculation function to allow returning only transactions that will probably be valid.

func (*TxMempool) Invalidate

func (t *TxMempool) Invalidate(id types.TransactionID)

Invalidate removes transaction from pool.

func (*TxMempool) Put

func (t *TxMempool) Put(id types.TransactionID, tx *types.Transaction)

Put inserts a transaction into the mem pool. It indexes it by source and dest addresses as well.

Jump to

Keyboard shortcuts

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