Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validators): refresh status count only once per hour #2961

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion services/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func startServicesMonitoringService() {
"statistics": time.Minute * 90,
"ethStoreStatistics": time.Minute * 15,
"lastExportedStatisticDay": time.Minute * 15,
"validatorStateCountsUpdater": time.Minute * 15,
"validatorStateCountsUpdater": time.Minute * 90,
//"notification-sender", //exclude for now as the sender is only running on mainnet
}

Expand Down
10 changes: 5 additions & 5 deletions services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1797,17 +1797,17 @@ func validatorStateCountsUpdater(wg *sync.WaitGroup) {
}
}
ReportStatus("validatorStateCountsUpdater", "Running", nil)
time.Sleep(time.Minute)
time.Sleep(time.Minute * 60)
}
}

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
}
Loading