If At Genesis or !ChainStarted, Return Healthy Sync Status (#2183)

* genesis or not chainstarted

* is synced

* lint

* tests pass
This commit is contained in:
Raul Jordan 2019-04-05 16:40:53 -05:00 committed by Preston Van Loon
parent de0f4ad278
commit 0d2d7a558f
3 changed files with 13 additions and 2 deletions

View File

@ -186,7 +186,10 @@ func (q *Querier) RequestLatestHead() {
// IsSynced checks if the node is currently synced with the
// rest of the network.
func (q *Querier) IsSynced() (bool, error) {
if q.chainStarted && q.atGenesis {
if !q.chainStarted {
return true, nil
}
if q.atGenesis {
return true, nil
}
block, err := q.db.ChainHead()

View File

@ -4,11 +4,11 @@ import (
"context"
"fmt"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/operations"
initialsync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
)
@ -91,6 +91,12 @@ func (ss *Service) Stop() error {
// Status checks the status of the node. It returns nil if it's synced
// with the rest of the network and no errors occurred. Otherwise, it returns an error.
func (ss *Service) Status() error {
if !ss.Querier.chainStarted {
return nil
}
if ss.Querier.atGenesis {
return nil
}
synced, currentSyncedSlot := ss.InitialSync.NodeIsSynced()
if !synced {
return fmt.Errorf(

View File

@ -223,6 +223,8 @@ func setUpUnSyncedService(simP2P *simulatedP2P, stateRoot [32]byte, t *testing.T
ss := NewSyncService(context.Background(), cfg)
go ss.run()
ss.Querier.chainStarted = true
ss.Querier.atGenesis = false
for ss.Querier.currentHeadSlot == 0 {
simP2P.Send(simP2P.ctx, &pb.ChainHeadResponse{