Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterMempoolMessages(cdc *amino.Codec)
- type Mempool
- func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error)
- func (mem *Mempool) CloseWAL() bool
- func (mem *Mempool) EnableTxsAvailable()
- func (mem *Mempool) Flush()
- func (mem *Mempool) FlushAppConn() error
- func (mem *Mempool) InitWAL()
- func (mem *Mempool) Lock()
- func (mem *Mempool) Reap(maxTxs int) types.Txs
- func (mem *Mempool) SetLogger(l log.Logger)
- func (mem *Mempool) Size() int
- func (mem *Mempool) TxsAvailable() <-chan int64
- func (mem *Mempool) TxsFront() *clist.CElement
- func (mem *Mempool) TxsWaitChan() <-chan struct{}
- func (mem *Mempool) Unlock()
- func (mem *Mempool) Update(height int64, txs types.Txs) error
- type MempoolMessage
- type MempoolReactor
- func (memR *MempoolReactor) AddPeer(peer p2p.Peer)
- func (memR *MempoolReactor) BroadcastTx(tx types.Tx, cb func(*abci.Response)) error
- func (memR *MempoolReactor) GetChannels() []*p2p.ChannelDescriptor
- func (memR *MempoolReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
- func (memR *MempoolReactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (memR *MempoolReactor) SetLogger(l log.Logger)
- type PeerState
- type TxMessage
Constants ¶
const (
MempoolChannel = byte(0x30)
)
Variables ¶
var ErrTxInCache = errors.New("Tx already exists in cache")
Functions ¶
func RegisterMempoolMessages ¶ added in v0.19.5
func RegisterMempoolMessages(cdc *amino.Codec)
Types ¶
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool is an ordered in-memory pool for transactions before they are proposed in a consensus round. Transaction validity is checked using the CheckTx abci message before the transaction is added to the pool. The Mempool uses a concurrent list structure for storing transactions that can be efficiently accessed by multiple concurrent readers.
func NewMempool ¶
func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int64) *Mempool
NewMempool returns a new Mempool with the given configuration and connection to an application. TODO: Extract logger into arguments.
func (*Mempool) CheckTx ¶
CheckTx executes a new transaction against the application to determine its validity and whether it should be added to the mempool. It blocks if we're waiting on Update() or Reap(). cb: A callback from the CheckTx command.
It gets called from another goroutine.
CONTRACT: Either cb will get called, or err returned.
func (*Mempool) CloseWAL ¶ added in v0.15.0
CloseWAL closes and discards the underlying WAL file. Any further writes will not be relayed to disk.
func (*Mempool) EnableTxsAvailable ¶ added in v0.10.5
func (mem *Mempool) EnableTxsAvailable()
EnableTxsAvailable initializes the TxsAvailable channel, ensuring it will trigger once every height when transactions are available. NOTE: not thread safe - should only be called once, on startup
func (*Mempool) Flush ¶
func (mem *Mempool) Flush()
Flush removes all transactions from the mempool and cache
func (*Mempool) FlushAppConn ¶ added in v0.19.5
Flushes the mempool connection to ensure async resCb calls are done e.g. from CheckTx.
func (*Mempool) Lock ¶
func (mem *Mempool) Lock()
Lock locks the mempool. The consensus must be able to hold lock to safely update.
func (*Mempool) Reap ¶
Reap returns a list of transactions currently in the mempool. If maxTxs is -1, there is no cap on the number of returned transactions.
func (*Mempool) TxsAvailable ¶ added in v0.10.5
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) TxsFront ¶ added in v0.19.5
TxsFront returns the first transaction in the ordered list for peer goroutines to call .NextWait() on.
func (*Mempool) TxsWaitChan ¶ added in v0.19.5
func (mem *Mempool) TxsWaitChan() <-chan struct{}
TxsWaitChan returns a channel to wait on transactions. It will be closed once the mempool is not empty (ie. the internal `mem.txs` has at least one element)
type MempoolMessage ¶
type MempoolMessage interface{}
MempoolMessage is a message sent or received by the MempoolReactor.
func DecodeMessage ¶
func DecodeMessage(bz []byte) (msg MempoolMessage, err error)
DecodeMessage decodes a byte-array into a MempoolMessage.
type MempoolReactor ¶
type MempoolReactor struct { p2p.BaseReactor Mempool *Mempool // contains filtered or unexported fields }
MempoolReactor handles mempool tx broadcasting amongst peers.
func NewMempoolReactor ¶
func NewMempoolReactor(config *cfg.MempoolConfig, mempool *Mempool) *MempoolReactor
NewMempoolReactor returns a new MempoolReactor with the given config and mempool.
func (*MempoolReactor) AddPeer ¶
func (memR *MempoolReactor) AddPeer(peer p2p.Peer)
AddPeer implements Reactor. It starts a broadcast routine ensuring all txs are forwarded to the given peer.
func (*MempoolReactor) BroadcastTx ¶
BroadcastTx is an alias for Mempool.CheckTx. Broadcasting itself happens in peer routines.
func (*MempoolReactor) GetChannels ¶
func (memR *MempoolReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor. It returns the list of channels for this reactor.
func (*MempoolReactor) Receive ¶
func (memR *MempoolReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
Receive implements Reactor. It adds any received transactions to the mempool.
func (*MempoolReactor) RemovePeer ¶
func (memR *MempoolReactor) RemovePeer(peer p2p.Peer, reason interface{})
RemovePeer implements Reactor.
func (*MempoolReactor) SetLogger ¶ added in v0.10.5
func (memR *MempoolReactor) SetLogger(l log.Logger)
SetLogger sets the Logger on the reactor and the underlying Mempool.