Skip to content

Commit

Permalink
return proper v2 error when getting an error from the `/eth/v2/beacon…
Browse files Browse the repository at this point in the history
…/blocks` endpoint
  • Loading branch information
pk910 committed Aug 25, 2023
1 parent 88fd471 commit 52f1c65
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rpc/beaconapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ func (bc *BeaconClient) GetBlockHeaderBySlot(slot uint64) (*rpctypes.StandardV1B

func (bc *BeaconClient) GetBlockBodyByBlockroot(blockroot []byte) (*rpctypes.StandardV2BeaconBlockResponse, error) {
resp, err := bc.get(fmt.Sprintf("%s/eth/v2/beacon/blocks/0x%x", bc.endpoint, blockroot))
disperr := err
if err != nil {
resp, err = bc.get(fmt.Sprintf("%s/eth/v1/beacon/blocks/0x%x", bc.endpoint, blockroot))
}
if err != nil {
return nil, fmt.Errorf("error retrieving block body for 0x%x: %v", blockroot, err)
return nil, fmt.Errorf("error retrieving block body for 0x%x: %v", blockroot, disperr)
}

var parsedResponse rpctypes.StandardV2BeaconBlockResponse
Expand Down

0 comments on commit 52f1c65

Please sign in to comment.