mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Eth2 API: node endpoints outline (#7522)
* Nodev1 outline * Gaz Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
2f6f79724f
commit
022b09f2e2
29
beacon-chain/rpc/nodev1/BUILD.bazel
Normal file
29
beacon-chain/rpc/nodev1/BUILD.bazel
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_test")
|
||||||
|
load("@prysm//tools/go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "go_default_library",
|
||||||
|
srcs = [
|
||||||
|
"node.go",
|
||||||
|
"server.go",
|
||||||
|
],
|
||||||
|
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/rpc/nodev1",
|
||||||
|
visibility = ["//beacon-chain:__subpackages__"],
|
||||||
|
deps = [
|
||||||
|
"//beacon-chain/blockchain:go_default_library",
|
||||||
|
"//beacon-chain/db:go_default_library",
|
||||||
|
"//beacon-chain/p2p:go_default_library",
|
||||||
|
"//beacon-chain/sync:go_default_library",
|
||||||
|
"@com_github_gogo_protobuf//types:go_default_library",
|
||||||
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
|
"@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library",
|
||||||
|
"@org_golang_google_grpc//:go_default_library",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
go_test(
|
||||||
|
name = "go_default_test",
|
||||||
|
srcs = ["server_test.go"],
|
||||||
|
embed = [":go_default_library"],
|
||||||
|
deps = ["@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library"],
|
||||||
|
)
|
48
beacon-chain/rpc/nodev1/node.go
Normal file
48
beacon-chain/rpc/nodev1/node.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package nodev1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
ptypes "github.com/gogo/protobuf/types"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetIdentity retrieves data about the node's network presence.
|
||||||
|
func (ns *Server) GetIdentity(ctx context.Context, _ *ptypes.Empty) (*ethpb.IdentityResponse, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPeer retrieves data about the given peer.
|
||||||
|
func (ns *Server) GetPeer(ctx context.Context, req *ethpb.PeerRequest) (*ethpb.PeerResponse, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPeers retrieves data about the node's network peers.
|
||||||
|
func (ns *Server) ListPeers(ctx context.Context, _ *ptypes.Empty) (*ethpb.PeersResponse, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVersion requests that the beacon node identify information about its implementation in a
|
||||||
|
// format similar to a HTTP User-Agent field.
|
||||||
|
func (ns *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.VersionResponse, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSyncStatus requests the beacon node to describe if it's currently syncing or not, and
|
||||||
|
// if it is, what block it is up to.
|
||||||
|
func (ns *Server) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncingResponse, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHealth returns node health status in http status codes. Useful for load balancers.
|
||||||
|
// Response Usage:
|
||||||
|
// "200":
|
||||||
|
// description: Node is ready
|
||||||
|
// "206":
|
||||||
|
// description: Node is syncing but can serve incomplete data
|
||||||
|
// "503":
|
||||||
|
// description: Node not initialized or having issues
|
||||||
|
func (ns *Server) GetHealth(ctx context.Context, _ *ptypes.Empty) (*ptypes.Empty, error) {
|
||||||
|
return nil, errors.New("unimplemented")
|
||||||
|
}
|
25
beacon-chain/rpc/nodev1/server.go
Normal file
25
beacon-chain/rpc/nodev1/server.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Package nodev1 defines a gRPC node service implementation, providing
|
||||||
|
// useful endpoints for checking a node's sync status, peer info,
|
||||||
|
// genesis data, and version information.
|
||||||
|
package nodev1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain"
|
||||||
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||||
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||||
|
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server defines a server implementation of the gRPC Node service,
|
||||||
|
// providing RPC endpoints for verifying a beacon node's sync status, genesis and
|
||||||
|
// version information.
|
||||||
|
type Server struct {
|
||||||
|
SyncChecker sync.Checker
|
||||||
|
Server *grpc.Server
|
||||||
|
BeaconDB db.ReadOnlyDatabase
|
||||||
|
PeersFetcher p2p.PeersProvider
|
||||||
|
PeerManager p2p.PeerManager
|
||||||
|
GenesisTimeFetcher blockchain.TimeFetcher
|
||||||
|
GenesisFetcher blockchain.GenesisFetcher
|
||||||
|
}
|
7
beacon-chain/rpc/nodev1/server_test.go
Normal file
7
beacon-chain/rpc/nodev1/server_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package nodev1
|
||||||
|
|
||||||
|
import (
|
||||||
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ ethpb.BeaconNodeServer = (*Server)(nil)
|
Loading…
Reference in New Issue
Block a user