Documentation
¶
Index ¶
- Constants
- Variables
- func IsPreCheckError(err error) bool
- func TxKey(tx types.Tx) [TxKeySize]byte
- type CListMempoolOption
- type ErrMempoolIsFull
- type ErrPreCheck
- type ErrTxTooLarge
- type Mempool
- func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response), txInfo tmmempl.TxInfo) error
- func (mem *Mempool) CloseWAL()
- func (mem *Mempool) EnableTxsAvailable()
- func (mem *Mempool) Flush()
- func (mem *Mempool) FlushAppConn() error
- func (mem *Mempool) InitWAL() error
- func (mem *Mempool) Lock()
- func (mem *Mempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) types.Txs
- func (mem *Mempool) ReapMaxTxs(max int) types.Txs
- func (mem *Mempool) RemoveTxByKey(txKey [TxKeySize]byte, removeFromCache bool)
- func (mem *Mempool) SetLogger(l log.Logger)
- func (mem *Mempool) Size() int
- func (mem *Mempool) TxsAvailable() <-chan struct{}
- func (mem *Mempool) TxsBytes() 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, deliverTxResponses []*abci.ResponseDeliverTx, ...) error
- type NotifyFunc
- type PeerState
- type Reactor
- func (memR *Reactor) AddPeer(peer p2p.Peer)
- func (memR *Reactor) GetChannels() []*p2p.ChannelDescriptor
- func (memR *Reactor) InitPeer(peer p2p.Peer) p2p.Peer
- func (memR *Reactor) OnStart() error
- func (memR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
- func (memR *Reactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (memR *Reactor) SetLogger(l log.Logger)
- type TxsMessage
Constants ¶
const ( MempoolChannel = byte(0x30) // UnknownPeerID is the peer ID to use when running CheckTx when there is // no peer (e.g. RPC) UnknownPeerID uint16 = 0 )
const TxKeySize = sha256.Size
TxKeySize is the size of the transaction key index
Variables ¶
var ( // ErrTxInCache is returned to the client if we saw tx earlier ErrTxInCache = errors.New("tx already exists in cache") )
Functions ¶
func IsPreCheckError ¶
IsPreCheckError returns true if err is due to pre check failure.
Types ¶
type CListMempoolOption ¶
type CListMempoolOption func(*Mempool)
CListMempoolOption sets an optional parameter on the mempool.
func WithMetrics ¶
func WithMetrics(metrics *tmmempl.Metrics) CListMempoolOption
WithMetrics sets the metrics.
func WithNotify ¶
func WithNotify(f NotifyFunc) CListMempoolOption
WithNotify sets a notification for the mempool. This is ran after a tx has been accepted by the mempool.
func WithPostCheck ¶
func WithPostCheck(f tmmempl.PostCheckFunc) CListMempoolOption
WithPostCheck sets a filter for the mempool to reject a tx if f(tx) returns false. This is ran after CheckTx. Only applies to the first created block. After that, Update overwrites the existing value.
func WithPreCheck ¶
func WithPreCheck(f tmmempl.PreCheckFunc) CListMempoolOption
WithPreCheck sets a filter for the mempool to reject a tx if f(tx) returns false. This is ran before CheckTx. Only applies to the first created block. After that, Update overwrites the existing value.
type ErrMempoolIsFull ¶
type ErrMempoolIsFull struct {
// contains filtered or unexported fields
}
ErrMempoolIsFull means Tendermint & an application can't handle that much load
func (ErrMempoolIsFull) Error ¶
func (e ErrMempoolIsFull) Error() string
type ErrPreCheck ¶
type ErrPreCheck struct {
Reason error
}
ErrPreCheck is returned when tx is too big
func (ErrPreCheck) Error ¶
func (e ErrPreCheck) Error() string
type ErrTxTooLarge ¶
type ErrTxTooLarge struct {
// contains filtered or unexported fields
}
ErrTxTooLarge means the tx is too big to be sent in a message to other peers
func (ErrTxTooLarge) Error ¶
func (e ErrTxTooLarge) Error() string
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 New ¶
func New( config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int64, options ...CListMempoolOption, ) *Mempool
NewCListMempool returns a new mempool with the given configuration and connection to an application.
func (*Mempool) CheckTx ¶
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.
Safe for concurrent use by multiple goroutines.
func (*Mempool) EnableTxsAvailable ¶
func (mem *Mempool) EnableTxsAvailable()
NOTE: not thread safe - should only be called once, on startup
func (*Mempool) Flush ¶
func (mem *Mempool) Flush()
XXX: Unsafe! Calling Flush may leave mempool in inconsistent state.
func (*Mempool) FlushAppConn ¶
Lock() must be help by the caller during execution.
func (*Mempool) ReapMaxBytesMaxGas ¶
Safe for concurrent use by multiple goroutines.
func (*Mempool) ReapMaxTxs ¶
Safe for concurrent use by multiple goroutines.
func (*Mempool) RemoveTxByKey ¶
RemoveTxByKey removes a transaction from the mempool by its TxKey index.
func (*Mempool) TxsAvailable ¶
func (mem *Mempool) TxsAvailable() <-chan struct{}
Safe for concurrent use by multiple goroutines.
func (*Mempool) TxsFront ¶
TxsFront returns the first transaction in the ordered list for peer goroutines to call .NextWait() on. FIXME: leaking implementation details!
Safe for concurrent use by multiple goroutines.
func (*Mempool) TxsWaitChan ¶
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)
Safe for concurrent use by multiple goroutines.
func (*Mempool) Unlock ¶
func (mem *Mempool) Unlock()
Safe for concurrent use by multiple goroutines.
func (*Mempool) Update ¶
func (mem *Mempool) Update( height int64, txs types.Txs, deliverTxResponses []*abci.ResponseDeliverTx, preCheck tmmempl.PreCheckFunc, postCheck tmmempl.PostCheckFunc, ) error
Lock() must be help by the caller during execution.
type NotifyFunc ¶
type PeerState ¶
type PeerState interface {
GetHeight() int64
}
PeerState describes the state of a peer.
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(config *cfg.MempoolConfig, mempool *Mempool) *Reactor
NewReactor returns a new Reactor with the given config and mempool.
func (*Reactor) AddPeer ¶
AddPeer implements Reactor. It starts a broadcast routine ensuring all txs are forwarded to the given peer.
func (*Reactor) GetChannels ¶
func (memR *Reactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor by returning the list of channels for this reactor.
func (*Reactor) Receive ¶
Receive implements Reactor. It adds any received transactions to the mempool.
func (*Reactor) RemovePeer ¶
RemovePeer implements Reactor.
type TxsMessage ¶
TxsMessage is a Message containing transactions.
func (*TxsMessage) String ¶
func (m *TxsMessage) String() string
String returns a string representation of the TxsMessage.