Improve reconnections + fixing unit tests

This commit is contained in:
Juan Leni
2019-04-03 14:15:50 +02:00
parent 37cc8db430
commit ab033fbc81
7 changed files with 56 additions and 43 deletions
+7 -2
View File
@@ -296,18 +296,23 @@ func NewNode(config *cfg.Config,
}
}
pubKey := privValidator.GetPubKey()
if pubKey == nil {
return nil, fmt.Errorf("could not retrieve pubkey")
}
// Decide whether to fast-sync or not
// We don't fast-sync when the only validator is us.
fastSync := config.FastSync
if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0)
privValAddr := privValidator.GetPubKey().Address()
privValAddr := pubKey.Address()
if bytes.Equal(privValAddr, addr) {
fastSync = false
}
}
pubKey := privValidator.GetPubKey()
addr := pubKey.Address()
// Log whether this node is a validator or an observer
if state.Validators.HasAddress(addr) {