This commit is contained in:
tycho garen
2021-06-14 08:18:53 -04:00
parent f8458a19d4
commit 3e30543246
3 changed files with 29 additions and 5 deletions
+24
View File
@@ -46,3 +46,27 @@ func (gs *groupImpl) OnReset() error {
}
return nil
}
type FunctionalService struct {
Starter func() error
Stopper func()
Reseter func() error
}
func MakeFunctionalService(logger log.Logger, name string, opts FunctionalService) Service {
srv := &funImpl{
opts: FunctionalService,
}
srv.BaseService = NewBaseService(logger, name, srv)
return srv
}
type funImpl struct {
*BaseService
ops FunctionalService
}
func (fs *funImpl) OnStart() error { return fs.ops.Starter() }
func (fs *funImpl) OnStop() { fs.ops.Stoper() }
func (fs *funImpl) OnReset() error { return fs.ops.Reseter() }
+1 -1
View File
@@ -191,7 +191,7 @@ func makeNode(config *cfg.Config,
}
// Determine whether we should attempt state sync.
stateSync := config.StateSync.Enable && !onlyValidatorIsUs(state, pubKey)
stateSync := config.StateSync.Enable && !onlyValidatorIsUs(genDoc, pubKey)
if stateSync && state.LastBlockHeight > 0 {
logger.Info("Found local state with non-zero height, skipping state sync")
stateSync = false
+4 -4
View File
@@ -182,12 +182,12 @@ func logNodeStartupInfo(state sm.State, pubKey crypto.PubKey, logger, consensusL
}
}
func onlyValidatorIsUs(state sm.State, pubKey crypto.PubKey) bool {
if state.Validators.Size() > 1 {
func onlyValidatorIsUs(genDoc *types.GenesisDoc, pubKey crypto.PubKey) bool {
if len(genDoc.Validators) > 1 || pubKey == nil {
return false
}
addr, _ := state.Validators.GetByIndex(0)
return pubKey != nil && bytes.Equal(pubKey.Address(), addr)
return bytes.Equal(pubKey.Address(), genDoc.Validators[0].Address)
}
func createMempoolReactor(