mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-31 09:03:46 +00:00
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package api
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/beacon/types"
|
|
)
|
|
|
|
type PortalLightApi struct {
|
|
}
|
|
|
|
func NewPortalLightApi() *PortalLightApi {
|
|
return &PortalLightApi{}
|
|
}
|
|
|
|
func (api *PortalLightApi) GetBestUpdatesAndCommittees(firstPeriod, count uint64) ([]*types.LightClientUpdate, []*types.SerializedSyncCommittee, error) {
|
|
//contentKey := &beacon.LightClientUpdateKey{
|
|
// StartPeriod: firstPeriod,
|
|
// Count: count,
|
|
//}
|
|
|
|
//resp, err := api.httpGetf("/eth/v1/beacon/light_client/updates?start_period=%d&count=%d", firstPeriod, count)
|
|
//if err != nil {
|
|
// return nil, nil, err
|
|
//}
|
|
//
|
|
//var data []CommitteeUpdate
|
|
//if err := json.Unmarshal(resp, &data); err != nil {
|
|
// return nil, nil, err
|
|
//}
|
|
//if len(data) != int(count) {
|
|
// return nil, nil, errors.New("invalid number of committee updates")
|
|
//}
|
|
//updates := make([]*types.LightClientUpdate, int(count))
|
|
//committees := make([]*types.SerializedSyncCommittee, int(count))
|
|
//for i, d := range data {
|
|
// if d.Update.AttestedHeader.Header.SyncPeriod() != firstPeriod+uint64(i) {
|
|
// return nil, nil, errors.New("wrong committee update header period")
|
|
// }
|
|
// if err := d.Update.Validate(); err != nil {
|
|
// return nil, nil, err
|
|
// }
|
|
// if d.NextSyncCommittee.Root() != d.Update.NextSyncCommitteeRoot {
|
|
// return nil, nil, errors.New("wrong sync committee root")
|
|
// }
|
|
// updates[i], committees[i] = new(types.LightClientUpdate), new(types.SerializedSyncCommittee)
|
|
// *updates[i], *committees[i] = d.Update, d.NextSyncCommittee
|
|
//}
|
|
//return updates, committees, nil
|
|
|
|
return nil, nil, errors.New("not implemented")
|
|
}
|