|
@ -115,10 +115,13 @@ type ConsensusState struct { |
|
|
// synchronous pubsub between consensus state and reactor.
|
|
|
// synchronous pubsub between consensus state and reactor.
|
|
|
// state only emits EventNewRoundStep, EventVote and EventProposalHeartbeat
|
|
|
// state only emits EventNewRoundStep, EventVote and EventProposalHeartbeat
|
|
|
evsw tmevents.EventSwitch |
|
|
evsw tmevents.EventSwitch |
|
|
|
|
|
|
|
|
|
|
|
// for reporting metrics
|
|
|
|
|
|
metrics *Metrics |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// NewConsensusState returns a new ConsensusState.
|
|
|
// NewConsensusState returns a new ConsensusState.
|
|
|
func NewConsensusState(config *cfg.ConsensusConfig, state sm.State, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, mempool sm.Mempool, evpool sm.EvidencePool) *ConsensusState { |
|
|
|
|
|
|
|
|
func NewConsensusState(config *cfg.ConsensusConfig, state sm.State, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, mempool sm.Mempool, evpool sm.EvidencePool, metrics *Metrics) *ConsensusState { |
|
|
cs := &ConsensusState{ |
|
|
cs := &ConsensusState{ |
|
|
config: config, |
|
|
config: config, |
|
|
blockExec: blockExec, |
|
|
blockExec: blockExec, |
|
@ -132,6 +135,7 @@ func NewConsensusState(config *cfg.ConsensusConfig, state sm.State, blockExec *s |
|
|
wal: nilWAL{}, |
|
|
wal: nilWAL{}, |
|
|
evpool: evpool, |
|
|
evpool: evpool, |
|
|
evsw: tmevents.NewEventSwitch(), |
|
|
evsw: tmevents.NewEventSwitch(), |
|
|
|
|
|
metrics: metrics, |
|
|
} |
|
|
} |
|
|
// set function defaults (may be overwritten before calling Start)
|
|
|
// set function defaults (may be overwritten before calling Start)
|
|
|
cs.decideProposal = cs.defaultDecideProposal |
|
|
cs.decideProposal = cs.defaultDecideProposal |
|
@ -388,6 +392,7 @@ func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *t |
|
|
|
|
|
|
|
|
func (cs *ConsensusState) updateHeight(height int64) { |
|
|
func (cs *ConsensusState) updateHeight(height int64) { |
|
|
cs.Height = height |
|
|
cs.Height = height |
|
|
|
|
|
cs.metrics.Height.Add(float64(height - cs.Height)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (cs *ConsensusState) updateRoundStep(round int, step cstypes.RoundStepType) { |
|
|
func (cs *ConsensusState) updateRoundStep(round int, step cstypes.RoundStepType) { |
|
|