NoEmptyBlocks config option

This commit is contained in:
Ethan Buchman
2017-07-28 22:11:45 -04:00
parent 4beac54bd9
commit 124032e3e9
4 changed files with 36 additions and 5 deletions
+21 -1
View File
@@ -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 {