prysm-pulse/validator/rpc/health.go

27 lines
786 B
Go
Raw Normal View History

package rpc
import (
"context"
ptypes "github.com/gogo/protobuf/types"
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
)
// GetBeaconNodeConnection retrieves the current beacon node connection
// information, as well as its sync status.
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
syncStatus, err := s.syncChecker.Syncing(ctx)
if err != nil || s.validatorService.Status() != nil {
return &pb.NodeConnectionResponse{
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: false,
Syncing: false,
}, nil
}
return &pb.NodeConnectionResponse{
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
Connected: true,
Syncing: syncStatus,
}, nil
}