mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-30 15:06:31 +00:00
f342224410
* deprecate db * fix build * begin integrating new db * gaz * use more of the new db * newest implementation uses head state * remove more deprecated items * setup validators in state helper * fix up some tests with the new db * resolve broken build * gaz * begin ensuring tests pass * optional idx * list validator balances passing * default page size passing * only two failing * fixed most tests, found edge case * allow nil return and add proper tests * pass tests * fix head block root problem * working with the new db * every ethereumapis method now compliant with both dbs * pass in db into server * proposer server all compliant * validator service fully compliant * fix broken build, tests pass * spacing * compute state root and propose block tests passing with new db * complete proposer server tests revamp * validator tests halfway through passing with new db * more validator server tests * more than halfway there * so so close * all validators tests done * attester server tests fixing * use new api * attester server complete * complete
62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"sort"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/version"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// NodeServer defines a server implementation of the gRPC Node service,
|
|
// providing RPC endpoints for verifying a beacon node's sync status, genesis and
|
|
// version information, and services the node implements and runs.
|
|
type NodeServer struct {
|
|
syncChecker sync.Checker
|
|
server *grpc.Server
|
|
beaconDB db.Database
|
|
}
|
|
|
|
// GetSyncStatus checks the current network sync status of the node.
|
|
func (ns *NodeServer) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncStatus, error) {
|
|
return ðpb.SyncStatus{
|
|
Syncing: ns.syncChecker.Syncing(),
|
|
}, nil
|
|
}
|
|
|
|
// GetGenesis fetches genesis chain information of Ethereum 2.0.
|
|
func (ns *NodeServer) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genesis, error) {
|
|
// TODO(3045): Use the getter from the blockchain service.
|
|
return nil, status.Error(codes.Unimplemented, "not implemented")
|
|
}
|
|
|
|
// GetVersion checks the version information of the beacon node.
|
|
func (ns *NodeServer) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.Version, error) {
|
|
return ðpb.Version{
|
|
Version: version.GetVersion(),
|
|
}, nil
|
|
}
|
|
|
|
// ListImplementedServices lists the services implemented and enabled by this node.
|
|
//
|
|
// Any service not present in this list may return UNIMPLEMENTED or
|
|
// PERMISSION_DENIED. The server may also support fetching services by grpc
|
|
// reflection.
|
|
func (ns *NodeServer) ListImplementedServices(ctx context.Context, _ *ptypes.Empty) (*ethpb.ImplementedServices, error) {
|
|
serviceInfo := ns.server.GetServiceInfo()
|
|
serviceNames := make([]string, 0, len(serviceInfo))
|
|
for svc := range serviceInfo {
|
|
serviceNames = append(serviceNames, svc)
|
|
}
|
|
sort.Strings(serviceNames)
|
|
return ðpb.ImplementedServices{
|
|
Services: serviceNames,
|
|
}, nil
|
|
}
|