mempool

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Channel = byte(0x30)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mempool

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

Mempool implements mempool.Mempool

func NewMempool

func NewMempool(cfg *config.AppConfig, logic core.Logic) *Mempool

NewMempool creates an instance of Mempool

func (*Mempool) Add

func (mp *Mempool) Add(tx types.BaseTx) (bool, error)

Add attempts to add a transaction to the pool

func (*Mempool) CacheSize

func (mp *Mempool) CacheSize() int

CacheSize returns the number of transactions in the mempool cache.

func (*Mempool) CheckTx

func (mp *Mempool) CheckTx(tx tmtypes.Tx, callback func(*abci.Response), txInfo mempool.TxInfo) error

CheckTx executes a new transaction against the application to determine its validity and whether it should be added to the mempool.

func (*Mempool) CloseWAL

func (mp *Mempool) CloseWAL()

CloseWAL closes and discards the underlying WAL file. Any further writes will not be relayed to disk.

func (*Mempool) EnableTxsAvailable

func (mp *Mempool) EnableTxsAvailable()

EnableTxsAvailable initializes the TxsAvailable channel, ensuring it will trigger once every height when transactions are available.

func (*Mempool) Flush

func (mp *Mempool) Flush()

Flush removes all transactions from the mempool and cache

func (*Mempool) FlushAppConn

func (mp *Mempool) FlushAppConn() error

FlushAppConn flushes the mempool connection to ensure async reqResCb calls are done. E.g. from CheckTx.

func (*Mempool) InitWAL

func (mp *Mempool) InitWAL() error

InitWAL implements mempool.Mempool

func (*Mempool) Lock

func (mp *Mempool) Lock()

Lock locks the mempool. The consensus must be able to hold lock to safely update.

func (*Mempool) ReapMaxBytesMaxGas

func (mp *Mempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) tmtypes.Txs

ReapMaxBytesMaxGas reaps transactions from the mempool up to maxBytes bytes total. If both maxBytes are negative, there is no cap on the size of all returned transactions. NOTE: maxGas is ignored since this mempool does not apply the concept of gas

func (*Mempool) ReapMaxTxs

func (mp *Mempool) ReapMaxTxs(max int) tmtypes.Txs

ReapMaxTxs reaps up to max transactions from the mempool. If max is negative, there is no cap on the size of all returned transactions (~ all available transactions).

func (*Mempool) SetProxyApp

func (mp *Mempool) SetProxyApp(proxyApp proxy.AppConnMempool)

SetProxyApp sets the proxy app connection for accessing ABCI app operations required by the mempool

func (*Mempool) Size

func (mp *Mempool) Size() int

Size returns the number of transactions in the mempool.

func (*Mempool) TxsAvailable

func (mp *Mempool) TxsAvailable() <-chan struct{}

TxsAvailable returns a channel which fires once for every height, and only when transactions are available in the mempool. NOTE: the returned channel may be nil if EnableTxsAvailable was not called.

func (*Mempool) TxsBytes

func (mp *Mempool) TxsBytes() int64

TxsBytes returns the total size of all txs in the mempool.

func (*Mempool) Unlock

func (mp *Mempool) Unlock()

Unlock unlocks the mempool.

func (*Mempool) Update

func (mp *Mempool) Update(
	blockHeight int64,
	txs tmtypes.Txs,
	responses []*abci.ResponseDeliverTx,
	_ mempool.PreCheckFunc,
	_ mempool.PostCheckFunc,
) error

Update informs the mempool that the given txs were committed and can be discarded. NOTE: this should be called *after* block is committed by consensus. NOTE: unsafe; Lock/Unlock must be managed by caller

type Option

type Option func(*Mempool)

Option sets an optional parameter on the mempool.

type Reactor

type Reactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

Reactor handles mempool tx broadcasting amongst peers. It maintains a map from peer ID to counter, to prevent gossiping txs to the peers you received it from.

func NewReactor

func NewReactor(cfg *config.AppConfig, mempool *Mempool) *Reactor

NewReactor returns a new Reactor with the given config and mempool.

func (*Reactor) AddPeer

func (r *Reactor) AddPeer(peer p2p.Peer)

AddPeer implements Reactor. It starts a broadcast routine ensuring all txs are forwarded to the given peer.

func (*Reactor) AddTx

func (r *Reactor) AddTx(tx types.BaseTx) (hash util.HexBytes, err error)

AddTx adds a transaction to the tx pool and broadcasts it.

func (*Reactor) GetChannels

func (r *Reactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor. It returns the list of channels for this reactor.

func (*Reactor) GetPoolSize

func (r *Reactor) GetPoolSize() *core.PoolSizeInfo

GetPoolSize returns the size information of the pool

func (*Reactor) GetTop

func (r *Reactor) GetTop(n int) []types.BaseTx

GetTop returns the top n transactions in the pool. It will return all transactions if n is zero or negative.

func (*Reactor) GetTx

func (r *Reactor) GetTx(hash string) types.BaseTx

GetTx finds and returns a transaction by hash

func (*Reactor) OnStart

func (r *Reactor) OnStart() error

OnStart implements p2p.BaseReactor.

func (*Reactor) Receive

func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)

Receive implements Reactor. It adds any received transactions to the mempool.

func (*Reactor) RemovePeer

func (r *Reactor) RemovePeer(peer p2p.Peer, reason interface{})

RemovePeer implements Reactor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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