Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion consensus/pbft/backends/simple/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var (
errUnknownBlock = errors.New("unknown block")
// errUnauthorized is returned if a header is signed by a non authorized entity.
errUnauthorized = errors.New("unauthorized")
// errNotInValidatorSet is returned if I'm not in validator set but try to start engine
errNotInValidatorSet = errors.New("not in validator set")
// errInvalidDifficulty is returned if the difficulty of a block is not 1
errInvalidDifficulty = errors.New("invalid difficulty")
// errNotProposer is returned when I'm not a proposer
Expand Down Expand Up @@ -435,6 +437,9 @@ func (sb *simpleBackend) Start(chain consensus.ChainReader, inserter func(block
if err := sb.initValidatorSet(chain); err != nil {
return err
}
if _, v := sb.valSet.GetByAddress(sb.address); v == nil {
return errNotInValidatorSet
}
sb.chain = chain
sb.inserter = inserter
sb.core = pbftCore.New(sb, sb.config)
Expand All @@ -455,7 +460,10 @@ func (sb *simpleBackend) Start(chain consensus.ChainReader, inserter func(block

// Stop implements consensus.PBFT.Stop
func (sb *simpleBackend) Stop() error {
return sb.core.Stop()
if sb.core != nil {
return sb.core.Stop()
}
return nil
}

func (sb *simpleBackend) initValidatorSet(chain consensus.ChainReader) error {
Expand Down