From 5b0dcab2d8ff509934ec1ab8db2b92d8b76ad301 Mon Sep 17 00:00:00 2001 From: peter <1674920+peterbitfly@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:34:55 +0000 Subject: [PATCH] fix(validators): fix retrieval of validator states from cache --- handlers/validators.go | 2 +- services/services.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers/validators.go b/handlers/validators.go index 0cdfe3a93b..cd61d43900 100644 --- a/handlers/validators.go +++ b/handlers/validators.go @@ -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 diff --git a/services/services.go b/services/services.go index f3208a36fd..b78f21451e 100644 --- a/services/services.go +++ b/services/services.go @@ -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 }