mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-09 06:33:16 +00:00
fixes from review
This commit is contained in:
@@ -47,7 +47,7 @@ func AddNodeFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable Peer-Exchange (dev feature)")
|
||||
|
||||
// consensus flags
|
||||
cmd.Flags().Bool("consensus.no_empty_blocks", config.Consensus.NoEmptyBlocks, "Prevent empty blocks from being proposed by correct processes")
|
||||
cmd.Flags().Bool("consensus.no_empty_blocks", config.Consensus.NoEmptyBlocks, "Only produce blocks when there are txs and when the AppHash changes")
|
||||
}
|
||||
|
||||
// Users wishing to:
|
||||
|
||||
@@ -790,9 +790,9 @@ func (cs *ConsensusState) enterNewRound(height int, round int) {
|
||||
func (cs *ConsensusState) waitForTxs(height, round int) {
|
||||
// if we're the proposer, start a heartbeat routine
|
||||
// to tell other peers we're just waiting for txs (for debugging)
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
if cs.isProposer() {
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
go cs.proposerHeartbeat(done)
|
||||
}
|
||||
|
||||
@@ -816,7 +816,8 @@ func (cs *ConsensusState) proposerHeartbeat(done chan struct{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// Enter: from enter NewRound(height,round), once txs are in the mempool
|
||||
// Enter (!NoEmptyBlocks): from enterNewRound(height,round)
|
||||
// Enter (NoEmptyBlocks) : after enterNewRound(height,round), once txs are in the mempool
|
||||
func (cs *ConsensusState) enterPropose(height int, round int) {
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPropose <= cs.Step) {
|
||||
cs.Logger.Debug(cmn.Fmt("enterPropose(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
|
||||
@@ -100,6 +100,7 @@ func NewMempool(config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool) *M
|
||||
|
||||
// FireOnTxsAvailable 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 (mem *Mempool) FireOnTxsAvailable() {
|
||||
mem.txsAvailable = make(chan struct{}, 1)
|
||||
}
|
||||
@@ -225,7 +226,7 @@ func (mem *Mempool) resCbNormal(req *abci.Request, res *abci.Response) {
|
||||
tx: req.GetCheckTx().Tx,
|
||||
}
|
||||
mem.txs.PushBack(memTx)
|
||||
mem.alertIfTxsAvailable()
|
||||
mem.notifyIfTxsAvailable()
|
||||
} else {
|
||||
// ignore bad transaction
|
||||
mem.logger.Info("Bad Transaction", "res", r)
|
||||
@@ -268,20 +269,13 @@ func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) {
|
||||
atomic.StoreInt32(&mem.rechecking, 0)
|
||||
mem.logger.Info("Done rechecking txs")
|
||||
|
||||
mem.alertIfTxsAvailable()
|
||||
mem.notifyIfTxsAvailable()
|
||||
}
|
||||
default:
|
||||
// ignore other messages
|
||||
}
|
||||
}
|
||||
|
||||
func (mem *Mempool) alertIfTxsAvailable() {
|
||||
if !mem.notifiedTxsAvailable && mem.Size() > 0 {
|
||||
mem.notifiedTxsAvailable = true
|
||||
mem.txsAvailable <- struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
@@ -292,7 +286,7 @@ func (mem *Mempool) TxsAvailable() chan struct{} {
|
||||
return mem.txsAvailable
|
||||
}
|
||||
|
||||
func (mem *Mempool) alertIfTxsAvailable() {
|
||||
func (mem *Mempool) notifyIfTxsAvailable() {
|
||||
if mem.txsAvailable != nil &&
|
||||
!mem.notifiedTxsAvailable && mem.Size() > 0 {
|
||||
|
||||
@@ -345,6 +339,8 @@ func (mem *Mempool) Update(height int, txs types.Txs) {
|
||||
}
|
||||
|
||||
// Set height
|
||||
// NOTE: the height is not set until Update is first called
|
||||
// (so it will be wrong after a restart until the next block)
|
||||
mem.height = height
|
||||
mem.notifiedTxsAvailable = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user