log whether node is a validator in each round

This commit is contained in:
Adrian Brink
2017-05-15 11:02:40 +02:00
committed by Ethan Buchman
parent e041b2eee6
commit eb9ca23250
3 changed files with 17 additions and 2 deletions

View File

@ -775,15 +775,21 @@ func (cs *ConsensusState) enterPropose(height int, round int) {
// Nothing more to do if we're not a validator
if cs.privValidator == nil {
cs.Logger.Info("This node is not a validator")
return
}
if !bytes.Equal(cs.Validators.GetProposer().Address, cs.privValidator.GetAddress()) {
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.Info("This node is a validator")
} else {
cs.Logger.Info("This node is not a validator")
}
} else {
cs.Logger.Info("enterPropose: Our turn to propose", "proposer", cs.Validators.GetProposer().Address, "privValidator", cs.privValidator)
cs.Logger.Info("This node is a validator")
cs.decideProposal(height, round)
}
}
@ -1141,6 +1147,7 @@ func (cs *ConsensusState) tryFinalizeCommit(height int) {
cs.Logger.Error("Attempt to finalize failed. We don't have the commit block.", "height", height, "proposal-block", cs.ProposalBlock.Hash(), "commit-block", blockID.Hash)
return
}
// go
cs.finalizeCommit(height)
}

View File

@ -123,6 +123,13 @@ func NewNode(config *cfg.Config, privValidator *types.PrivValidator, clientCreat
}
}
// Log whether this node is a validator or an observer
if state.Validators.HasAddress(privValidator.Address) {
consensusLogger.Info("This node is a validator")
} else {
consensusLogger.Info("This node is not a validator")
}
// Make BlockchainReactor
bcReactor := bc.NewBlockchainReactor(state.Copy(), proxyApp.Consensus(), blockStore, fastSync)
bcReactor.SetLogger(logger.With("module", "blockchain"))

View File

@ -151,6 +151,7 @@ func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader typ
s.logger.Error("Error changing validator set", "error", err)
// TODO: err or carry on?
}
// Update validator accums and set state variables
nextValSet.IncrementAccum(1)