fix print buckets issue

This commit is contained in:
alex.sharov 2021-02-09 14:39:31 +07:00
parent 7464b7924d
commit bb55ea81a4
2 changed files with 9 additions and 4 deletions

View File

@ -212,7 +212,7 @@ func SpawnExecuteBlocksStage(s *StageState, stateDB ethdb.Database, chainConfig
if err = tx.CommitAndBegin(context.Background()); err != nil {
return err
}
if err = printBucketsSize(tx.(ethdb.HasTx).Tx()); err != nil {
if err = printBucketsSize(tx); err != nil {
return err
}
chainContext.SetDB(tx)
@ -233,7 +233,7 @@ func SpawnExecuteBlocksStage(s *StageState, stateDB ethdb.Database, chainConfig
if err = tx.CommitAndBegin(context.Background()); err != nil {
return err
}
if err = printBucketsSize(tx.(ethdb.HasTx).Tx()); err != nil {
if err = printBucketsSize(tx); err != nil {
return err
}
chainContext.SetDB(tx)

View File

@ -209,14 +209,19 @@ func (s *State) Run(db ethdb.GetterPutter, tx ethdb.GetterPutter) error {
runtime.ReadMemStats(&m)
log.Info("Memory", "alloc", common.StorageSize(m.Alloc), "sys", common.StorageSize(m.Sys))
log.Info("Timings", timings...)
if err := printBucketsSize(tx.(ethdb.HasTx).Tx()); err != nil {
if err := printBucketsSize(tx); err != nil {
return err
}
return nil
}
//nolint
func printBucketsSize(tx ethdb.Tx) error {
func printBucketsSize(dbTx ethdb.Getter) error {
hasTx, ok := dbTx.(ethdb.HasTx)
if !ok {
return nil
}
tx := hasTx.Tx()
if tx == nil {
return nil
}