Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterMempoolMessages()
- type App
- type MemFunc
- type Mempool
- func (mem *Mempool) AddTx(peerID string, tx types.Tx) (err error)
- func (mem *Mempool) EnableTxsAvailable()
- func (mem *Mempool) GetTxFromCache(hash common.Hash) types.Tx
- func (mem *Mempool) GoodTxsSize() int
- func (m *Mempool) KeyImageExists(key lktypes.Key) bool
- func (m *Mempool) KeyImagePush(key lktypes.Key) bool
- func (m *Mempool) KeyImageRemove(key lktypes.Key)
- func (m *Mempool) KeyImageRemoveKeys(keys []*lktypes.Key)
- func (m *Mempool) KeyImageReset()
- func (mem *Mempool) Lock()
- func (mem *Mempool) Reap(maxTxs int) types.Txs
- func (mem *Mempool) SetApp(a App)
- func (mem *Mempool) SetLogger(l log.Logger)
- func (mem *Mempool) SetReceiveP2pTx(on bool)
- func (mem *Mempool) SpecGoodTxsSize() int
- func (mem *Mempool) Stats() (int, int, int)
- func (mem *Mempool) Stop()
- func (mem *Mempool) TxsAvailable() <-chan struct{}
- func (mem *Mempool) UTXOTxsSize() int
- func (mem *Mempool) Unlock()
- func (mem *Mempool) Update(height uint64, txs types.Txs) error
- type MempoolMessage
- type MempoolReactor
- func (memR *MempoolReactor) AddPeer(peer p2p.Peer)
- func (memR *MempoolReactor) GetChannels() []*p2p.ChannelDescriptor
- func (memR *MempoolReactor) GetMutilSignCache() *clist.CList
- func (memR *MempoolReactor) GetRecvCache() *clist.CList
- func (memR *MempoolReactor) OnStart() error
- 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 Metrics
- type PeerState
- type RecieveMessage
- type TxHashMessage
- type TxHashMessageKind
- type TxMessage
Constants ¶
const ( BasicCheck = true StateCheck = false )
BasicCheck for check signature in checkTX
const ( //MempoolChannel ID MempoolChannel = byte(0x30) ReceiveCacheMaxLength = 10000 // Max Length of Receive )
Variables ¶
var ( // GoodTxRebroadcastTime determines when to rebroadcast goodTx GoodTxRebroadcastTime = 30 * time.Second // GoodTxDropTime determines when to drop goodTx GoodTxDropTime = 60 * time.Second )
var (
// BroadcastTxFunc is called when we broadcast tx
BroadcastTxFunc = defaultBroadcastTx
)
var ErrTxNotATransaction = fmt.Errorf("tx is not a transaction")
ErrTxNotATransaction ...
var (
HandleReceiveMsgFunc = defaultHandReceiveMsg
)
Functions ¶
func RegisterMempoolMessages ¶
func RegisterMempoolMessages()
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, height uint64, sw p2p.P2PManager, options ...MemFunc) *Mempool
NewMempool returns a new Mempool with the given configuration and height.
func (*Mempool) AddTx ¶
AddTx add good txs in a concurrent linked-list @Note: Caller should print the error log
func (*Mempool) EnableTxsAvailable ¶
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) GetTxFromCache ¶ added in v0.1.1
GetTxFromCache ...
func (*Mempool) GoodTxsSize ¶
GoodTxsSize returns goodTxs list length.
func (*Mempool) KeyImageRemove ¶
func (*Mempool) KeyImageRemoveKeys ¶
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) SpecGoodTxsSize ¶
SpecGoodTxsSize returns specGoodList length.
func (*Mempool) Stats ¶
Stats retrieves the current pool stats, namely the number of pending and the number of queued (non-executable) transactions.
func (*Mempool) TxsAvailable ¶
func (mem *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) UTXOTxsSize ¶ added in v0.1.1
UTXOTxsSize return pure utxoTxs list length.
type MempoolMessage ¶
type MempoolMessage interface{}
MempoolMessage is a message sent or received by the MempoolReactor.
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) GetChannels ¶
func (memR *MempoolReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor. It returns the list of channels for this reactor.
func (*MempoolReactor) GetMutilSignCache ¶
func (memR *MempoolReactor) GetMutilSignCache() *clist.CList
func (*MempoolReactor) GetRecvCache ¶
func (memR *MempoolReactor) GetRecvCache() *clist.CList
func (*MempoolReactor) OnStart ¶
func (memR *MempoolReactor) OnStart() error
OnStart implements p2p.BaseReactor.
func (*MempoolReactor) Receive ¶
func (memR *MempoolReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
Receive implements Reactor. It adds any received transactions to the cache.
func (*MempoolReactor) RemovePeer ¶
func (memR *MempoolReactor) RemovePeer(peer p2p.Peer, reason interface{})
RemovePeer implements Reactor.
func (*MempoolReactor) SetLogger ¶
func (memR *MempoolReactor) SetLogger(l log.Logger)
SetLogger sets the Logger on the reactor and the underlying Mempool.
type Metrics ¶
Metrics contains metrics exposed by this package. see MetricsProvider for descriptions.
func PrometheusMetrics ¶
func PrometheusMetrics() *Metrics
PrometheusMetrics returns Metrics build using Prometheus client library.
type PeerState ¶
type PeerState interface {
GetHeight() uint64
}
PeerState describes the state of a peer.
type RecieveMessage ¶
type TxHashMessage ¶ added in v0.1.1
type TxHashMessage struct { Hashs []common.Hash Kind TxHashMessageKind }
TxHashMessage --
func (TxHashMessage) String ¶ added in v0.1.1
func (m TxHashMessage) String() string
type TxHashMessageKind ¶ added in v0.1.1
type TxHashMessageKind int
const ( TxHashNotify TxHashMessageKind TxHashRequest )