mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-25 17:34:36 +00:00
NoEmptyBlocks config option
This commit is contained in:
+21
-1
@@ -92,13 +92,18 @@ func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool) *M
|
||||
recheckEnd: nil,
|
||||
logger: log.NewNopLogger(),
|
||||
cache: newTxCache(cacheSize),
|
||||
txsAvailable: make(chan struct{}, 1),
|
||||
}
|
||||
mempool.initWAL()
|
||||
proxyAppConn.SetResponseCallback(mempool.resCb)
|
||||
return mempool
|
||||
}
|
||||
|
||||
// FireOnTxsAvailable initializes the TxsAvailable channel,
|
||||
// ensuring it will trigger once every height when transactions are available.
|
||||
func (mem *Mempool) FireOnTxsAvailable() {
|
||||
mem.txsAvailable = make(chan struct{}, 1)
|
||||
}
|
||||
|
||||
// SetLogger sets the Logger.
|
||||
func (mem *Mempool) SetLogger(l log.Logger) {
|
||||
mem.logger = l
|
||||
@@ -277,10 +282,25 @@ func (mem *Mempool) alertIfTxsAvailable() {
|
||||
}
|
||||
}
|
||||
|
||||
// TxsAvailable returns a channel which fires once for every height,
|
||||
// and only when transactions are available in the mempool.
|
||||
// XXX: Will panic if mem.FireOnTxsAvailable() has not been called.
|
||||
func (mem *Mempool) TxsAvailable() chan struct{} {
|
||||
if mem.txsAvailable == nil {
|
||||
panic("mem.txsAvailable is nil")
|
||||
}
|
||||
return mem.txsAvailable
|
||||
}
|
||||
|
||||
func (mem *Mempool) alertIfTxsAvailable() {
|
||||
if mem.txsAvailable != nil &&
|
||||
!mem.notifiedTxsAvailable && mem.Size() > 0 {
|
||||
|
||||
mem.notifiedTxsAvailable = true
|
||||
mem.txsAvailable <- struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 (mem *Mempool) Reap(maxTxs int) types.Txs {
|
||||
|
||||
Reference in New Issue
Block a user