From 7968637d4257d2d3cebb4a8a9eea380a39f57da1 Mon Sep 17 00:00:00 2001 From: Artem Vorotnikov Date: Thu, 25 Mar 2021 01:48:08 +0300 Subject: [PATCH] ObjectDatabase cleanup (#1598) * ObjectDatabase cleanup * Remove ObjectDatabase::WarmUp --- ethdb/id.go | 9 --------- ethdb/object_db.go | 35 ++--------------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 ethdb/id.go diff --git a/ethdb/id.go b/ethdb/id.go deleted file mode 100644 index ffe016622..000000000 --- a/ethdb/id.go +++ /dev/null @@ -1,9 +0,0 @@ -package ethdb - -import "sync/atomic" - -var dbID = new(uint64) - -func id() uint64 { - return atomic.AddUint64(dbID, 1) -} diff --git a/ethdb/object_db.go b/ethdb/object_db.go index 9ecf7e2e6..1aa79105b 100644 --- a/ethdb/object_db.go +++ b/ethdb/object_db.go @@ -22,7 +22,6 @@ import ( "context" "fmt" "strings" - "time" "github.com/google/btree" "github.com/ledgerwatch/lmdb-go/lmdb" @@ -38,18 +37,13 @@ type DbCopier interface { // ObjectDatabase - is an object-style interface of DB accessing type ObjectDatabase struct { - kv KV - log log.Logger - id uint64 + kv KV } // NewObjectDatabase returns a AbstractDB wrapper. func NewObjectDatabase(kv KV) *ObjectDatabase { - logger := log.New("database", "object") return &ObjectDatabase{ - kv: kv, - log: logger, - id: id(), + kv: kv, } } @@ -425,28 +419,3 @@ func NewDatabaseWithFreezer(db *ObjectDatabase, dir, suffix string) (*ObjectData // FIXME: implement freezer in Turbo-Geth return db, nil } - -func WarmUp(tx Tx, bucket string, logEvery *time.Ticker, quit <-chan struct{}) error { - count := 0 - c := tx.Cursor(bucket) - totalKeys, errCount := c.Count() - if errCount != nil { - return errCount - } - for k, _, err := c.First(); k != nil; k, _, err = c.Next() { - if err != nil { - return err - } - count++ - - select { - default: - case <-quit: - return common.ErrStopped - case <-logEvery.C: - log.Info("Warmed up state", "progress", fmt.Sprintf("%.2fM/%.2fM", float64(count)/1_000_000, float64(totalKeys)/1_000_000)) - } - } - - return nil -}