mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
83af9a5694
* making needed changes to beacon API based on removal of blobsidecar from block contents * fixing tests and reverting some changes to be addressed later * fixing generated code from protos * gaz * fixing get blob handler and adding blob storage to the blob service * updating unit tests * WIP * wip tests * got tests passing but needs cleanup * removing gomod and gosum changes * fixing more tests * fixing more tests * fixing more tests * gaz * moving some proto types around * removing unneeded unit test * fixing proposer paths * adding more tests * fixing more tests * improving more unit tests * updating one blob only unit test * changing arguments of buildBlobSidecar * reverting a change based on feedback * terence's review items * fixing test based on new develop changes * radek's comments * addressed more comments from radek * adding in blobs to test data * fixing casing in test * removing extra line * fixing issue from bad merge * Update beacon-chain/rpc/eth/beacon/handlers_test.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update beacon-chain/rpc/eth/beacon/handlers_test.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update beacon-chain/rpc/eth/beacon/handlers_test.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update beacon-chain/rpc/eth/blob/handlers.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * moving core getblob business logic to blocker based on radek's comment * fixing mock blocker * gaz --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
55 lines
971 B
Go
55 lines
971 B
Go
package core
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
)
|
|
|
|
type ErrorReason uint8
|
|
|
|
const (
|
|
Internal = iota
|
|
Unavailable
|
|
BadRequest
|
|
NotFound
|
|
// Add more errors as needed
|
|
)
|
|
|
|
type RpcError struct {
|
|
Err error
|
|
Reason ErrorReason
|
|
}
|
|
|
|
func ErrorReasonToGRPC(reason ErrorReason) codes.Code {
|
|
switch reason {
|
|
case Internal:
|
|
return codes.Internal
|
|
case Unavailable:
|
|
return codes.Unavailable
|
|
case BadRequest:
|
|
return codes.InvalidArgument
|
|
case NotFound:
|
|
return codes.NotFound
|
|
// Add more cases for other error reasons as needed
|
|
default:
|
|
return codes.Internal
|
|
}
|
|
}
|
|
|
|
func ErrorReasonToHTTP(reason ErrorReason) int {
|
|
switch reason {
|
|
case Internal:
|
|
return http.StatusInternalServerError
|
|
case Unavailable:
|
|
return http.StatusServiceUnavailable
|
|
case BadRequest:
|
|
return http.StatusBadRequest
|
|
case NotFound:
|
|
return http.StatusNotFound
|
|
// Add more cases for other error reasons as needed
|
|
default:
|
|
return http.StatusInternalServerError
|
|
}
|
|
}
|