From 5dda2ca328831a7c05f8292e18302caea67fdf6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kapka?= Date: Tue, 12 Jan 2021 17:20:20 +0100 Subject: [PATCH] Replace HTTP code with gRPC code in GetHealth API endpoint (#8249) * Replace HTTP code with gRPC code in GetHealth API endpoint * gazelle Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/rpc/nodev1/BUILD.bazel | 1 + beacon-chain/rpc/nodev1/node.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/beacon-chain/rpc/nodev1/BUILD.bazel b/beacon-chain/rpc/nodev1/BUILD.bazel index bd15ba06f..9410394d4 100644 --- a/beacon-chain/rpc/nodev1/BUILD.bazel +++ b/beacon-chain/rpc/nodev1/BUILD.bazel @@ -20,6 +20,7 @@ go_library( "@com_github_prysmaticlabs_ethereumapis//eth/v1:go_default_library", "@io_opencensus_go//trace:go_default_library", "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//status:go_default_library", ], ) diff --git a/beacon-chain/rpc/nodev1/node.go b/beacon-chain/rpc/nodev1/node.go index 3707a9b83..a6280c91e 100644 --- a/beacon-chain/rpc/nodev1/node.go +++ b/beacon-chain/rpc/nodev1/node.go @@ -3,7 +3,6 @@ package nodev1 import ( "context" "fmt" - "net/http" "runtime" ptypes "github.com/gogo/protobuf/types" @@ -11,6 +10,7 @@ import ( ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1" "github.com/prysmaticlabs/prysm/shared/version" "go.opencensus.io/trace" + "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -64,5 +64,5 @@ func (ns *Server) GetHealth(ctx context.Context, _ *ptypes.Empty) (*ptypes.Empty if ns.SyncChecker.Syncing() || ns.SyncChecker.Initialized() { return &ptypes.Empty{}, nil } - return &ptypes.Empty{}, status.Error(http.StatusInternalServerError, "node not initialized or having issues") + return &ptypes.Empty{}, status.Error(codes.Internal, "node not initialized or having issues") }