Skip to content

Commit

Permalink
Merge pull request #2528 from gobitfly/NOBIDS/ImproveValidatorStats
Browse files Browse the repository at this point in the history
Nobids/improve validator stats
recy21 authored Sep 4, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents d78aa9d + 68902dc commit 690403c
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/misc/main.go
Original file line number Diff line number Diff line change
@@ -466,7 +466,7 @@ func CompareRewards(dayStart uint64, dayEnd uint64, validator uint64, bt *db.Big
err = db.ReaderDb.Get(&dbRewards, `
SELECT
COALESCE(cl_rewards_gwei, 0) AS cl_rewards_gwei
FROM validator_stats WHERE day = $1 and validatorindex = $2`, day, validator)
FROM validator_stats WHERE validatorindex = $2 AND day = $1`, day, validator)
if err != nil {
logrus.Fatalf("error getting cl_rewards_gwei from db: %v", err)
return
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
@@ -3284,7 +3284,7 @@ func GetValidatorBalanceForDay(validators []uint64, day uint64, balance *uint64)
SELECT
COALESCE(SUM(end_balance), 0)
FROM validator_stats
WHERE day=$2 AND validatorindex = ANY($1)
WHERE validatorindex = ANY($1) AND day = $2
`, validatorsPQArray, day)
}

4 changes: 2 additions & 2 deletions handlers/validator.go
Original file line number Diff line number Diff line change
@@ -575,9 +575,9 @@ func Validator(w http.ResponseWriter, r *http.Request) {
MissedAttestations uint64 `db:"missed_attestations"`
}{}
if lastStatsDay > 0 {
err = db.ReaderDb.Get(&attestationStats, "select coalesce(sum(missed_attestations), 0) as missed_attestations from validator_stats where validatorindex = $1", index)
err = db.ReaderDb.Get(&attestationStats, "SELECT missed_attestations_total AS missed_attestations FROM validator_stats WHERE validatorindex = $1 AND day = $2", index, lastStatsDay)
if err != nil {
return fmt.Errorf("error retrieving validator attestationStats: %v", err)
return fmt.Errorf("error retrieving validator attestationStats: %w", err)
}
}

0 comments on commit 690403c

Please sign in to comment.