From 39493bcd9a26f1d19e1a407fbe23da1938bf9d87 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 11 Jul 2017 19:18:15 -0400 Subject: [PATCH] consensus: isProposer func --- consensus/state.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/consensus/state.go b/consensus/state.go index 415f6af3..6259a620 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -804,7 +804,7 @@ func (cs *ConsensusState) enterPropose(height int, round int) { return } - if !bytes.Equal(cs.Validators.GetProposer().Address, cs.privValidator.GetAddress()) { + if !cs.isProposer() { cs.Logger.Info("enterPropose: Not our turn to propose", "proposer", cs.Validators.GetProposer().Address, "privValidator", cs.privValidator) if cs.Validators.HasAddress(cs.privValidator.GetAddress()) { cs.Logger.Debug("This node is a validator") @@ -818,6 +818,10 @@ func (cs *ConsensusState) enterPropose(height int, round int) { } } +func (cs *ConsensusState) isProposer() bool { + return bytes.Equal(cs.Validators.GetProposer().Address, cs.privValidator.GetAddress()) +} + func (cs *ConsensusState) defaultDecideProposal(height, round int) { var block *types.Block var blockParts *types.PartSet