-
Notifications
You must be signed in to change notification settings - Fork 1.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
POST version of GetValidators and GetValidatorBalances #13199
Conversation
if r.Method == http.MethodGet { | ||
rawIds = r.URL.Query()["id"] | ||
} else { | ||
err = json.NewDecoder(r.Body).Decode(&rawIds) |
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.
I saw the spec and this list should be a unique list of IDs, i don't think decodeIds is checking for uniqueness.
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.
I don't see it anywhere in the spec. It is a useful thing to add, but I would prefer to have it in another PR.
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.
3 minors comments
@@ -72,7 +93,12 @@ func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request) { | |||
epoch := slots.ToEpoch(st.Slot()) | |||
allBalances := st.Balances() | |||
|
|||
statuses := r.URL.Query()["status"] | |||
var statuses []string | |||
if r.Method == http.MethodGet { |
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 grouping rawIds
and statuses
to reduce the number of r.Method == http.MethodGet
?
(Not sure what is the most idiomatic in that case.)
Like:
var rawIds []string
var statuses []string
if r.Method == http.MethodGet {
rawIds = r.URL.Query()["id"]
statuses = r.URL.Query()["status"]
} else {
rawIds = req.Ids
statuses = req.Statuses
}
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.
done
if r.Method == http.MethodPost { | ||
err = json.NewDecoder(r.Body).Decode(&req) | ||
switch { | ||
case err == io.EOF: |
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.
Those errors case seem not to be tested.
(Not sure about the testing policy in that case.)
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.
done
} else { | ||
err = json.NewDecoder(r.Body).Decode(&rawIds) | ||
switch { | ||
case err == io.EOF: |
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.
Those errors case seem not to be tested.
(Not sure about the testing policy in that case.)
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.
done
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Implements ethereum/beacon-APIs#367. I also simplified testing to use less validators.
Which issues(s) does this PR fix?
Fixes #13187