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

(NOBIDS) fix rare error cases when some data is not yet present #2843

Merged
merged 1 commit into from
Feb 28, 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
3 changes: 3 additions & 0 deletions db/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,9 @@ func GetCurrentDayClIncome(validator_indices []uint64) (map[uint64]int64, error)
dayIncome := make(map[uint64]int64)
lastDay, err := GetLastExportedStatisticDay()
if err != nil {
if err == ErrNoStats {
return dayIncome, nil
}
return dayIncome, err
}

Expand Down
8 changes: 7 additions & 1 deletion handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,13 @@ func getSyncCommitteeSlotsStatistics(validators []uint64, epoch uint64) (types.S
lastExportedEpoch = ((lastExportedDay + 1) * epochsPerDay) - 1
}

err = db.ReaderDb.Get(&syncStats, `SELECT SUM(COALESCE(participated_sync_total, 0)) AS participated, SUM(COALESCE(missed_sync_total, 0)) AS missed FROM validator_stats WHERE day = $1 AND validatorindex = ANY($2)`, lastExportedDay, pq.Array(validators))
err = db.ReaderDb.Get(&syncStats, `
SELECT
COALESCE(SUM(COALESCE(participated_sync_total, 0)), 0) AS participated,
COALESCE(SUM(COALESCE(missed_sync_total, 0)),0) AS missed
FROM validator_stats
WHERE day = $1 AND validatorindex = ANY($2)
`, lastExportedDay, pq.Array(validators))
if err != nil {
return types.SyncCommitteesStats{}, err
}
Expand Down
Loading