mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
If At Genesis or !ChainStarted, Return Healthy Sync Status (#2183)
* genesis or not chainstarted * is synced * lint * tests pass
This commit is contained in:
parent
de0f4ad278
commit
0d2d7a558f
@ -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()
|
||||
|
@ -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(
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user