Skip to content

Commit

Permalink
storage/stats: query sum from transaction_summary table
Browse files Browse the repository at this point in the history
  • Loading branch information
RaghavSood committed Jun 11, 2024
1 parent bf359b9 commit 8e0f00d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion storage/sqlite/index_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ func (d *SqliteBackend) GetIndexStatistics(height int64) (types.IndexStatistics,
stats.LastBlockHeight = lastBlock.BlockHeight
stats.LastBlockTime = lastBlock.BlockTimestamp

err = d.db.QueryRow("SELECT COUNT(*), SUM(amount) FROM losses WHERE block_height <= ?", lastBlock.BlockHeight).Scan(&stats.BurnOutputCount, &stats.BurnedSupply)
err = d.db.QueryRow("SELECT COUNT(*) FROM losses WHERE block_height <= ?", lastBlock.BlockHeight).Scan(&stats.BurnOutputCount)
if err != nil {
return stats, err
}

err = d.db.QueryRow("SELECT SUM(total_loss) FROM transaction_summary WHERE block_height <= ?", lastBlock.BlockHeight).Scan(&stats.BurnedSupply)

err = d.db.QueryRow("SELECT COUNT(*) FROM burn_scripts").Scan(&stats.BurnScriptsCount)
if err != nil {
return stats, err
Expand Down

0 comments on commit 8e0f00d

Please sign in to comment.