ObjectDatabase cleanup (#1598)

* ObjectDatabase cleanup

* Remove ObjectDatabase::WarmUp
This commit is contained in:
Artem Vorotnikov 2021-03-25 01:48:08 +03:00 committed by GitHub
parent ea15c4a4fd
commit 7968637d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 42 deletions

View File

@ -1,9 +0,0 @@
package ethdb
import "sync/atomic"
var dbID = new(uint64)
func id() uint64 {
return atomic.AddUint64(dbID, 1)
}

View File

@ -22,7 +22,6 @@ import (
"context"
"fmt"
"strings"
"time"
"github.com/google/btree"
"github.com/ledgerwatch/lmdb-go/lmdb"
@ -39,17 +38,12 @@ type DbCopier interface {
// ObjectDatabase - is an object-style interface of DB accessing
type ObjectDatabase struct {
kv KV
log log.Logger
id uint64
}
// NewObjectDatabase returns a AbstractDB wrapper.
func NewObjectDatabase(kv KV) *ObjectDatabase {
logger := log.New("database", "object")
return &ObjectDatabase{
kv: kv,
log: logger,
id: id(),
}
}
@ -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
}