mempool

package
v0.78.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConflict is returned when transaction being added is incompatible
	// with the contents of the memory pool (using the same inputs as some
	// other transaction in the pool)
	ErrConflict = errors.New("conflicts with the memory pool")
	// ErrDup is returned when transaction being added is already present
	// in the memory pool.
	ErrDup = errors.New("already in the memory pool")
	// ErrOOM is returned when transaction just doesn't fit in the memory
	// pool because of its capacity constraints.
	ErrOOM = errors.New("out of memory")
)

Functions

This section is empty.

Types

type Feer

type Feer interface {
	BlockHeight() uint32
	NetworkFee(t *transaction.Transaction) util.Fixed8
	IsLowPriority(util.Fixed8) bool
	FeePerByte(t *transaction.Transaction) util.Fixed8
	SystemFee(t *transaction.Transaction) util.Fixed8
}

Feer is an interface that abstract the implementation of the fee calculation.

type Pool

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

Pool stores the unconfirms transactions.

func NewMemPool

func NewMemPool(capacity int) Pool

NewMemPool returns a new Pool struct.

func (*Pool) Add

func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error

Add tries to add given transaction to the Pool.

func (*Pool) ContainsKey

func (mp *Pool) ContainsKey(hash util.Uint256) bool

ContainsKey checks if a transactions hash is in the Pool.

func (*Pool) Count

func (mp *Pool) Count() int

Count returns the total number of uncofirm transactions.

func (*Pool) GetVerifiedTransactions

func (mp *Pool) GetVerifiedTransactions() []TxWithFee

GetVerifiedTransactions returns a slice of Input from all the transactions in the memory pool whose hash is not included in excludedHashes.

func (*Pool) Remove

func (mp *Pool) Remove(hash util.Uint256)

Remove removes an item from the mempool, if it exists there (and does nothing if it doesn't).

func (*Pool) RemoveStale

func (mp *Pool) RemoveStale(isOK func(*transaction.Transaction) bool, height uint32)

RemoveStale filters verified transactions through the given function keeping only the transactions for which it returns a true result. It's used to quickly drop part of the mempool that is now invalid after the block acceptance.

func (*Pool) SetResendThreshold added in v0.78.2

func (mp *Pool) SetResendThreshold(h uint32, f func(*transaction.Transaction))

SetResendThreshold sets threshold after which transaction will be considered stale and returned for retransmission by `GetStaleTransactions`.

func (*Pool) TryGetValue

func (mp *Pool) TryGetValue(hash util.Uint256) (*transaction.Transaction, util.Fixed8, bool)

TryGetValue returns a transaction and its fee if it exists in the memory pool.

func (*Pool) Verify

func (mp *Pool) Verify(tx *transaction.Transaction) bool

Verify verifies if the inputs of a transaction tx are already used in any other transaction in the memory pool. If yes, the transaction tx is not a valid transaction and the function return false. If no, the transaction tx is a valid transaction and the function return true.

type TxWithFee

type TxWithFee struct {
	Tx  *transaction.Transaction
	Fee util.Fixed8
}

TxWithFee combines transaction and its precalculated network fee.

Jump to

Keyboard shortcuts

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