-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP endpoint for GetChainHead
#14262
Conversation
beacon-chain/rpc/endpoints.go
Outdated
template: "/prysm/v1/beacon/chain_head", | ||
name: namespace + ".GetChainHead", | ||
middleware: []mux.MiddlewareFunc{ | ||
middleware.ContentTypeHandler([]string{api.JsonMediaType}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need the content type handler for get requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, it's a copy paste error
beacon-chain/rpc/core/beacon.go
Outdated
Reason: Internal, | ||
} | ||
} | ||
if err := consensusblocks.BeaconBlockIsNil(headBlock); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make more sense to move this before the optimistic check
response := &structs.ChainHead{ | ||
HeadSlot: fmt.Sprintf("%d", ch.HeadSlot), | ||
HeadEpoch: fmt.Sprintf("%d", ch.HeadEpoch), | ||
HeadBlockRoot: fmt.Sprintf("%#x", ch.HeadBlockRoot), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use hexutil.Encode
for consistency with other root fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep missed that one, ty
|
||
s.GetChainHead(writer, request) | ||
require.Equal(t, http.StatusOK, writer.Code) | ||
// require.StringContains(t, "could not get genesis block", writer.Body.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment
What type of PR is this?
Other
What does this PR do? Why is it needed?
Adding the HTTP endpoint for
GetChainHead
.Which issues(s) does this PR fix?
N/A
Other notes for review