Skip to content

Commit

Permalink
(BIDS-2369) account for statistics refarctor
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly committed Sep 28, 2023
1 parent 187e69a commit 325f579
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion db/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func WriteValidatorStatisticsForDay(day uint64) error {

// update mev reward total
data.MEVRewardsWeiTotal = previousDayData.MEVRewardsWeiTotal.Add(data.MEVRewardsWei)

// update withdrawal total
data.WithdrawalsTotal = previousDayData.WithdrawalsTotal + data.Withdrawals
data.WithdrawalsAmountTotal = previousDayData.WithdrawalsAmountTotal + data.WithdrawalsAmount
}

conn, err := WriterDb.Conn(context.Background())
Expand Down Expand Up @@ -233,7 +237,9 @@ func WriteValidatorStatisticsForDay(day uint64) error {
"deposits",
"deposits_amount",
"withdrawals",
"withdrawals_total",
"withdrawals_amount",
"withdrawals_amount_total",
"cl_rewards_gwei",
"cl_rewards_gwei_total",
"el_rewards_wei",
Expand Down Expand Up @@ -269,7 +275,9 @@ func WriteValidatorStatisticsForDay(day uint64) error {
validatorData[i].Deposits,
validatorData[i].DepositsAmount,
validatorData[i].Withdrawals,
validatorData[i].WithdrawalsTotal,
validatorData[i].WithdrawalsAmount,
validatorData[i].WithdrawalsAmountTotal,
validatorData[i].ClRewardsGWei,
validatorData[i].ClRewardsGWeiTotal,
validatorData[i].ElRewardsWei,
Expand Down Expand Up @@ -840,7 +848,8 @@ func gatherStatisticsForDay(day int64) ([]*types.ValidatorStatsTableDbRow, error
COALESCE(deposits, 0) AS deposits,
COALESCE(deposits_amount, 0) AS deposits_amount,
COALESCE(withdrawals, 0) AS withdrawals,
COALESCE(withdrawals_amount, 0) AS withdrawals_amount,
COALESCE(withdrawals_total, 0) AS withdrawals_total,
COALESCE(withdrawals_amount_total, 0) AS withdrawals_amount_total,
COALESCE(cl_rewards_gwei, 0) AS cl_rewards_gwei,
COALESCE(cl_rewards_gwei_total, 0) AS cl_rewards_gwei_total,
COALESCE(el_rewards_wei, 0) AS el_rewards_wei,
Expand Down
6 changes: 4 additions & 2 deletions types/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,10 @@ type ValidatorStatsTableDbRow struct {
Deposits int64 `db:"deposits"`
DepositsAmount int64 `db:"deposits_amount"`

Withdrawals int64 `db:"withdrawals"`
WithdrawalsAmount int64 `db:"withdrawals_amount"`
Withdrawals int64 `db:"withdrawals"`
WithdrawalsTotal int64 `db:"withdrawals_total"`
WithdrawalsAmount int64 `db:"withdrawals_amount"`
WithdrawalsAmountTotal int64 `db:"withdrawals_amount_total"`

ClRewardsGWei int64 `db:"cl_rewards_gwei"`
ClRewardsGWeiTotal int64 `db:"cl_rewards_gwei_total"`
Expand Down

0 comments on commit 325f579

Please sign in to comment.