mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
9c21809c50
* Add REST implementation for `ValidatorStatus` * Fix review comments
42 lines
935 B
Go
42 lines
935 B
Go
package beacon_api
|
|
|
|
import (
|
|
neturl "net/url"
|
|
|
|
"github.com/pkg/errors"
|
|
rpcmiddleware "github.com/prysmaticlabs/prysm/v3/beacon-chain/rpc/apimiddleware"
|
|
)
|
|
|
|
func (c *beaconApiValidatorClient) getStateValidators(
|
|
stringPubkeys []string,
|
|
statuses []string,
|
|
) (*rpcmiddleware.StateValidatorsResponseJson, error) {
|
|
params := neturl.Values{}
|
|
|
|
for _, stringPubkey := range stringPubkeys {
|
|
params.Add("id", stringPubkey)
|
|
}
|
|
|
|
for _, status := range statuses {
|
|
params.Add("status", status)
|
|
}
|
|
|
|
url := buildURL(
|
|
"/eth/v1/beacon/states/head/validators",
|
|
params,
|
|
)
|
|
|
|
stateValidatorsJson := &rpcmiddleware.StateValidatorsResponseJson{}
|
|
|
|
_, err := c.jsonRestHandler.GetRestJsonResponse(url, stateValidatorsJson)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to get json response")
|
|
}
|
|
|
|
if stateValidatorsJson.Data == nil {
|
|
return nil, errors.New("stateValidatorsJson.Data is nil")
|
|
}
|
|
|
|
return stateValidatorsJson, nil
|
|
}
|