Skip to content

Commit

Permalink
Provide validator beacon status in api
Browse files Browse the repository at this point in the history
  • Loading branch information
alrevuelta committed Oct 14, 2024
1 parent da6bcee commit d7fd2c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ func (m *ApiService) handleMemoryValidators(w http.ResponseWriter, req *http.Req
validatorsResp := make([]httpOkValidatorInfo, 0)
for _, v := range validators {
validatorsResp = append(validatorsResp, httpOkValidatorInfo{
// TODO: BeaconValidatorStatus: beaconState.Status.String(),
ValidatorStatus: v.ValidatorStatus.String(),
AccumulatedRewardsWei: v.AccumulatedRewardsWei.String(),
PendingRewardsWei: v.PendingRewardsWei.String(),
Expand Down Expand Up @@ -590,6 +591,7 @@ func (m *ApiService) handleMemoryValidatorsByIndex(w http.ResponseWriter, req *h
if validator, found := m.oracle.State().Validators[index]; found {
// Convert ValidatorInfo to httpOkValidatorInfo. This is done to return strings instead of bigInts
foundValidator := httpOkValidatorInfo{
// TODO: BeaconValidatorStatus: beaconState.Status.String(),
ValidatorStatus: validator.ValidatorStatus.String(),
AccumulatedRewardsWei: validator.AccumulatedRewardsWei.String(),
PendingRewardsWei: validator.PendingRewardsWei.String(),
Expand Down Expand Up @@ -658,9 +660,9 @@ func (m *ApiService) handleMemoryValidatorsByWithdrawal(w http.ResponseWriter, r
}

// Skip validators that cannot be subscribed
if !oracle.CanValidatorSubscribeToPool(validator) {
continue
}
//if !oracle.CanValidatorSubscribeToPool(validator) {
// continue
//}

requestedValidators[uint64(valIndex)] = &oracle.ValidatorInfo{
ValidatorStatus: oracle.Untracked,
Expand Down Expand Up @@ -736,8 +738,13 @@ func (m *ApiService) handleMemoryValidatorsByWithdrawal(w http.ResponseWriter, r

validatorsResp := make([]httpOkValidatorInfo, 0)
for _, v := range values {
beaconState, found := m.Onchain.Validators()[phase0.ValidatorIndex(v.ValidatorIndex)]
// TODO: Do something if not found
_ = found
validatorsResp = append(validatorsResp, httpOkValidatorInfo{
// TODO: BeaconValidatorStatus: beaconState.Status.String(),
ValidatorStatus: v.ValidatorStatus.String(),
BeaconValidatorStatus: beaconState.Status.String(),
AccumulatedRewardsWei: v.AccumulatedRewardsWei.String(),
PendingRewardsWei: v.PendingRewardsWei.String(),
CollateralWei: v.CollateralWei.String(),
Expand Down
1 change: 1 addition & 0 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type httpOkBlock struct {

type httpOkValidatorInfo struct {
ValidatorStatus string `json:"status"`
BeaconValidatorStatus string `json:"beacon_status"`
AccumulatedRewardsWei string `json:"accumulated_rewards_wei"`
PendingRewardsWei string `json:"pending_rewards_wei"`
CollateralWei string `json:"collateral_wei"`
Expand Down

0 comments on commit d7fd2c8

Please sign in to comment.