mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 02:31:19 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
37 lines
1004 B
Go
37 lines
1004 B
Go
package beacon_api
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type aggregatedSelectionResponse struct {
|
|
Data []iface.BeaconCommitteeSelection `json:"data"`
|
|
}
|
|
|
|
func (c *beaconApiValidatorClient) getAggregatedSelection(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) {
|
|
body, err := json.Marshal(selections)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to marshal selections")
|
|
}
|
|
|
|
var resp aggregatedSelectionResponse
|
|
err = c.jsonRestHandler.Post(ctx, "/eth/v1/validator/beacon_committee_selections", nil, bytes.NewBuffer(body), &resp)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "error calling post endpoint")
|
|
}
|
|
if len(resp.Data) == 0 {
|
|
return nil, errors.New("no aggregated selection returned")
|
|
}
|
|
if len(selections) != len(resp.Data) {
|
|
return nil, errors.New("mismatching number of selections")
|
|
}
|
|
|
|
return resp.Data, nil
|
|
}
|