erigon-pulse/core/rawdb/rawdbhelpers/rawdbhelpers.go
2023-06-11 21:12:05 +07:00

21 lines
494 B
Go

package rawdbhelpers
import (
"encoding/binary"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/eth/ethconfig"
)
func IdxStepsCountV3(tx kv.Tx) float64 {
fst, _ := kv.FirstKey(tx, kv.TblTracesToKeys)
lst, _ := kv.LastKey(tx, kv.TblTracesToKeys)
if len(fst) > 0 && len(lst) > 0 {
fstTxNum := binary.BigEndian.Uint64(fst)
lstTxNum := binary.BigEndian.Uint64(lst)
return float64(lstTxNum-fstTxNum) / float64(ethconfig.HistoryV3AggregationStep)
}
return 0
}