mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
ObjectDatabase cleanup (#1598)
* ObjectDatabase cleanup * Remove ObjectDatabase::WarmUp
This commit is contained in:
parent
ea15c4a4fd
commit
7968637d42
@ -1,9 +0,0 @@
|
|||||||
package ethdb
|
|
||||||
|
|
||||||
import "sync/atomic"
|
|
||||||
|
|
||||||
var dbID = new(uint64)
|
|
||||||
|
|
||||||
func id() uint64 {
|
|
||||||
return atomic.AddUint64(dbID, 1)
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/btree"
|
"github.com/google/btree"
|
||||||
"github.com/ledgerwatch/lmdb-go/lmdb"
|
"github.com/ledgerwatch/lmdb-go/lmdb"
|
||||||
@ -39,17 +38,12 @@ type DbCopier interface {
|
|||||||
// ObjectDatabase - is an object-style interface of DB accessing
|
// ObjectDatabase - is an object-style interface of DB accessing
|
||||||
type ObjectDatabase struct {
|
type ObjectDatabase struct {
|
||||||
kv KV
|
kv KV
|
||||||
log log.Logger
|
|
||||||
id uint64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewObjectDatabase returns a AbstractDB wrapper.
|
// NewObjectDatabase returns a AbstractDB wrapper.
|
||||||
func NewObjectDatabase(kv KV) *ObjectDatabase {
|
func NewObjectDatabase(kv KV) *ObjectDatabase {
|
||||||
logger := log.New("database", "object")
|
|
||||||
return &ObjectDatabase{
|
return &ObjectDatabase{
|
||||||
kv: kv,
|
kv: kv,
|
||||||
log: logger,
|
|
||||||
id: id(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,28 +419,3 @@ func NewDatabaseWithFreezer(db *ObjectDatabase, dir, suffix string) (*ObjectData
|
|||||||
// FIXME: implement freezer in Turbo-Geth
|
// FIXME: implement freezer in Turbo-Geth
|
||||||
return db, nil
|
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user