mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 02:02:18 +00:00
e100fb0c08
* add support for sync committee selections * go mod tidy * remove unused fields * fix build * fix build --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
36 lines
1019 B
Go
36 lines
1019 B
Go
package beacon_api
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
|
|
)
|
|
|
|
type aggregatedSyncSelectionResponse struct {
|
|
Data []iface.SyncCommitteeSelection `json:"data"`
|
|
}
|
|
|
|
func (c *beaconApiValidatorClient) getAggregatedSyncSelections(ctx context.Context, selections []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) {
|
|
body, err := json.Marshal(selections)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to marshal selections")
|
|
}
|
|
|
|
var resp aggregatedSyncSelectionResponse
|
|
err = c.jsonRestHandler.Post(ctx, "/eth/v1/validator/sync_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 sync selections returned")
|
|
}
|
|
if len(selections) != len(resp.Data) {
|
|
return nil, errors.New("mismatching number of sync selections")
|
|
}
|
|
|
|
return resp.Data, nil
|
|
}
|