zero division fix

This commit is contained in:
Marcel 2025-05-07 01:11:04 +08:00 committed by GitHub
parent 3eeae7c1c3
commit c698290536
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,9 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
var (
now = mclock.Now()
elapsed = now.Sub(st.startTime)
if elapsed == 0 { // prevent zero division
elapsed = 1
}
mgasps = float64(st.usedGas) * 1000 / float64(elapsed)
)
// Update the Mgas per second gauge