2020-09-03 23:25:56 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-09-08 20:54:56 +00:00
|
|
|
"time"
|
2020-09-03 23:25:56 +00:00
|
|
|
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
|
|
|
)
|
|
|
|
|
2020-09-08 20:02:12 +00:00
|
|
|
// GetBeaconNodeConnection retrieves the current beacon node connection
|
|
|
|
// information, as well as its sync status.
|
2020-09-03 23:25:56 +00:00
|
|
|
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
|
|
|
|
syncStatus, err := s.syncChecker.Syncing(ctx)
|
2020-09-08 20:02:12 +00:00
|
|
|
if err != nil || s.validatorService.Status() != nil {
|
|
|
|
return &pb.NodeConnectionResponse{
|
2020-09-08 22:35:31 +00:00
|
|
|
GenesisTime: 0,
|
|
|
|
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
|
|
|
|
Connected: false,
|
|
|
|
Syncing: false,
|
2020-09-08 20:02:12 +00:00
|
|
|
}, nil
|
2020-09-03 23:25:56 +00:00
|
|
|
}
|
2020-10-01 18:53:36 +00:00
|
|
|
genesis, err := s.genesisFetcher.GenesisInfo(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-03 23:25:56 +00:00
|
|
|
return &pb.NodeConnectionResponse{
|
2020-09-08 20:54:56 +00:00
|
|
|
GenesisTime: uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix()),
|
|
|
|
DepositContractAddress: genesis.DepositContractAddress,
|
|
|
|
BeaconNodeEndpoint: s.nodeGatewayEndpoint,
|
|
|
|
Connected: true,
|
|
|
|
Syncing: syncStatus,
|
2020-09-03 23:25:56 +00:00
|
|
|
}, nil
|
|
|
|
}
|