Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Finished the BeaconApiProvider impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jclapis committed May 24, 2024
1 parent b3fc41e commit 185862a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 14 deletions.
79 changes: 66 additions & 13 deletions manager/beacon-interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@ package manager

import (
"context"
"fmt"

"github.com/rocket-pool/node-manager-core/beacon/client"
)

func (m *BeaconMockManager) Node_Syncing(ctx context.Context) (client.SyncStatusResponse, error) {
// Get the slots
currentSlot := m.GetCurrentSlot()
highestSlot := m.GetHighestSlot()

// Write the response
response := client.SyncStatusResponse{}
response.Data.IsSyncing = (currentSlot < highestSlot)
response.Data.HeadSlot = client.Uinteger(highestSlot)
response.Data.SyncDistance = client.Uinteger(highestSlot - currentSlot)
return response, nil
}

func (m *BeaconMockManager) Beacon_Validators(ctx context.Context, stateId string, ids []string) (client.ValidatorsResponse, error) {
// Get the validators
validators, err := m.GetValidators(ids)
Expand All @@ -36,3 +24,68 @@ func (m *BeaconMockManager) Beacon_Validators(ctx context.Context, stateId strin
}
return response, nil
}

func (m *BeaconMockManager) Node_Syncing(ctx context.Context) (client.SyncStatusResponse, error) {
// Get the slots
currentSlot := m.GetCurrentSlot()
highestSlot := m.GetHighestSlot()

// Write the response
response := client.SyncStatusResponse{}
response.Data.IsSyncing = (currentSlot < highestSlot)
response.Data.HeadSlot = client.Uinteger(highestSlot)
response.Data.SyncDistance = client.Uinteger(highestSlot - currentSlot)
return response, nil
}

// ===========
// === NYI ===
// ===========

func (m *BeaconMockManager) Beacon_Attestations(ctx context.Context, blockId string) (client.AttestationsResponse, bool, error) {
return client.AttestationsResponse{}, false, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_Block(ctx context.Context, blockId string) (client.BeaconBlockResponse, bool, error) {
return client.BeaconBlockResponse{}, false, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_BlsToExecutionChanges_Post(ctx context.Context, request client.BLSToExecutionChangeRequest) error {
return fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_Committees(ctx context.Context, stateId string, epoch *uint64) (client.CommitteesResponse, error) {
return client.CommitteesResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_FinalityCheckpoints(ctx context.Context, stateId string) (client.FinalityCheckpointsResponse, error) {
return client.FinalityCheckpointsResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_Genesis(ctx context.Context) (client.GenesisResponse, error) {
return client.GenesisResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_Header(ctx context.Context, blockId string) (client.BeaconBlockHeaderResponse, bool, error) {
return client.BeaconBlockHeaderResponse{}, false, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Beacon_VoluntaryExits_Post(ctx context.Context, request client.VoluntaryExitRequest) error {
return fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Config_DepositContract(ctx context.Context) (client.Eth2DepositContractResponse, error) {
return client.Eth2DepositContractResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Config_Spec(ctx context.Context) (client.Eth2ConfigResponse, error) {
return client.Eth2ConfigResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Validator_DutiesProposer(ctx context.Context, indices []string, epoch uint64) (client.ProposerDutiesResponse, error) {
return client.ProposerDutiesResponse{}, fmt.Errorf("not implemented")
}

func (m *BeaconMockManager) Validator_DutiesSync_Post(ctx context.Context, indices []string, epoch uint64) (client.SyncDutiesResponse, error) {
return client.SyncDutiesResponse{}, fmt.Errorf("not implemented")
}
2 changes: 1 addition & 1 deletion server/add-validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func (s *BeaconMockServer) addValidator(w http.ResponseWriter, r *http.Request)
response := api.AddValidatorResponse{
Index: validator.Index,
}
handleSuccess(w, s.logger, response)
handleSuccess(s.logger, w, response)
}

0 comments on commit 185862a

Please sign in to comment.