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>
This commit is contained in:
Radosław Kapka 2021-01-12 17:20:20 +01:00 committed by GitHub
parent 470d5aa491
commit 5dda2ca328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -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",
],
)

View File

@ -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")
}