Skip to content

Commit

Permalink
fix(validators): fix retrieval of validator states from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbitfly committed Sep 30, 2024
1 parent 18f32b3 commit 5b0dcab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion handlers/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Validators(w http.ResponseWriter, r *http.Request) {

currentStateCounts := services.LatestValidatorStateCounts()

for _, state := range currentStateCounts {
for _, state := range *currentStateCounts {
switch state.Name {
case "pending":
validatorsPageData.PendingCount = state.Count
Expand Down
8 changes: 4 additions & 4 deletions services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1801,13 +1801,13 @@ func validatorStateCountsUpdater(wg *sync.WaitGroup) {
}
}

func LatestValidatorStateCounts() []types.ValidatorStateCountRow {
func LatestValidatorStateCounts() *[]types.ValidatorStateCountRow {
wanted := []types.ValidatorStateCountRow{}
cacheKey := fmt.Sprintf("%d:frontend:validator_state_counts", utils.Config.Chain.ClConfig.DepositChainID)
if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Minute, wanted); err == nil {
return wanted.([]types.ValidatorStateCountRow)
if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Minute, &wanted); err == nil {
return wanted.(*[]types.ValidatorStateCountRow)
} else {
logger.Errorf("error retrieving validator state count data from cache: %v", err)
}
return wanted
return &wanted
}

1 comment on commit 5b0dcab

@FELLIX000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Please sign in to comment.