Skip to content

Commit

Permalink
fix: fix lint err
Browse files Browse the repository at this point in the history
  • Loading branch information
flywukong committed Jan 18, 2024
1 parent fa33477 commit 8b18c3d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 33 deletions.
11 changes: 4 additions & 7 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
var triedb *trie.Database
if cacheConfig.SeparateTrieConfig != nil {
separatedTrieConfig := cacheConfig.SeparateTrieConfig
log.Info("node run with separated trie database", "directory", separatedTrieConfig.TrieDataDir)
log.Info("node run with separated trie database", "directory", separatedTrieConfig.TrieDataDir,
"db engine", separatedTrieConfig.SeparateDBEngine)
separateDir := filepath.Join(separatedTrieConfig.TrieDataDir, separatedTrieConfig.TrieName)
// open the separated db to init the trie database which only store the trie data
separateDB, dbErr := rawdb.Open(rawdb.OpenOptions{
Type: separatedTrieConfig.SeparateDBEngine,
Directory: separateDir,
Expand Down Expand Up @@ -410,10 +412,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
bc.flushInterval.Store(int64(cacheConfig.TrieTimeLimit))
bc.forker = NewForkChoice(bc, shouldPreserve)
bc.stateCache = state.NewDatabaseWithNodeDB(bc.db, bc.triedb)
// validator may already been inited in the EnableBlockValidator function in the option
if bc.validator == nil {
bc.validator = NewBlockValidator(chainConfig, bc, engine)
}
bc.validator = NewBlockValidator(chainConfig, bc, engine)
bc.prefetcher = NewStatePrefetcher(chainConfig, bc, engine)
bc.processor = NewStateProcessor(chainConfig, bc, engine)

Expand Down Expand Up @@ -551,15 +550,13 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
}
bc.snaps, _ = snapshot.New(snapconfig, bc.db, bc.triedb, head.Root, int(bc.cacheConfig.TriesInMemory), bc.stateCache.NoTries())
}

// do options before start any routine
for _, option := range options {
bc, err = option(bc)
if err != nil {
return nil, err
}
}

// Start future block processor.
bc.wg.Add(1)
go bc.updateFutureBlocks()
Expand Down
2 changes: 0 additions & 2 deletions core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@ type OpenOptions struct {
DisableFreeze bool
IsLastOffset bool
PruneAncientData bool
IsSeparateDB bool // indicates if it is a separated db which stored snapshot, meta and block data.
IsSingleTrieDB bool // indicates if it is a separated which stored trie data.
}

// openKeyValueDatabase opens a disk-based key-value database, e.g. leveldb or pebble.
Expand Down
1 change: 0 additions & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func (s *stateObject) getOriginStorage(key common.Hash) (common.Hash, bool) {
if value, cached := s.originStorage[key]; cached {
return value, true
}

// if L1 cache miss, try to get it from shared pool
if s.sharedOriginStorage != nil {
val, ok := s.sharedOriginStorage.Load(key)
Expand Down
6 changes: 3 additions & 3 deletions eth/filters/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
b.Log("Running bloombits benchmark section size:", sectionSize)

db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false, false, false)
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false)
if err != nil {
b.Fatalf("error opening database at %v: %v", benchDataDir, err)
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
for i := 0; i < benchFilterCnt; i++ {
if i%20 == 0 {
db.Close()
db, _ = rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false, false, false)
db, _ = rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false)
backend = &testBackend{db: db, sections: cnt}
sys = NewFilterSystem(backend, Config{})
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func BenchmarkNoBloomBits(b *testing.B) {
b.Skip("test disabled: this tests presume (and modify) an existing datadir.")
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
b.Log("Running benchmark without bloombits")
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false, false, false)
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false)
if err != nil {
b.Fatalf("error opening database at %v: %v", benchDataDir, err)
}
Expand Down
1 change: 0 additions & 1 deletion ethdb/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func NewCustom(file string, namespace string, customize func(options *opt.Option
log: logger,
quitChan: make(chan chan error),
}

ldb.compTimeMeter = metrics.NewRegisteredMeter(namespace+"compact/time", nil)
ldb.compReadMeter = metrics.NewRegisteredMeter(namespace+"compact/input", nil)
ldb.compWriteMeter = metrics.NewRegisteredMeter(namespace+"compact/output", nil)
Expand Down
1 change: 0 additions & 1 deletion ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
if handles < minHandles {
handles = minHandles
}

logger := log.New("database", file)

// The max memtable size is limited by the uint32 offsets stored in
Expand Down
34 changes: 16 additions & 18 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ func (n *Node) OpenAndMergeDatabase(name string, cache, handles int, freezer, di
chainDataHandles := handles
if persistDiff {
chainDataHandles = handles * chainDataHandlesPercentage / 100
log.Info("persist diff is true", "handler", chainDataHandles)
}
chainDB, err := n.OpenDatabaseWithFreezer(name, cache, chainDataHandles, freezer, namespace, readonly, false, false, pruneAncientData)
if err != nil {
Expand Down Expand Up @@ -833,6 +832,9 @@ func (n *Node) OpenDatabaseWithFreezer(name string, cache, handles int, ancient,
return db, err
}

// OpenTrieDataBase opens an existing database to store the trie data with the given name (or
// creates one if no previous can be found) from within the node's data directory.
// This function is only used in scenarios where the separate db is used.
func (n *Node) OpenTrieDataBase(name string, cache, handles int, ancient, namespace string, readonly, disableFreeze, isLastOffset, pruneAncientData bool) (ethdb.Database, error) {
n.lock.Lock()
defer n.lock.Unlock()
Expand All @@ -841,23 +843,19 @@ func (n *Node) OpenTrieDataBase(name string, cache, handles int, ancient, namesp
}
var db ethdb.Database
var err error
if n.config.DataDir == "" {
db = rawdb.NewMemoryDatabase()
} else {
separateDir := filepath.Join(n.config.GetTrieDir(), name)
db, err = rawdb.Open(rawdb.OpenOptions{
Type: n.config.DBEngine,
Directory: separateDir,
AncientsDirectory: filepath.Join(separateDir, ancient),
Namespace: namespace,
Cache: cache,
Handles: handles,
ReadOnly: readonly,
DisableFreeze: disableFreeze,
IsLastOffset: isLastOffset,
PruneAncientData: pruneAncientData,
})
}
separateDir := filepath.Join(n.config.GetTrieDir(), name)
db, err = rawdb.Open(rawdb.OpenOptions{
Type: n.config.DBEngine,
Directory: separateDir,
AncientsDirectory: filepath.Join(separateDir, ancient),
Namespace: namespace,
Cache: cache,
Handles: handles,
ReadOnly: readonly,
DisableFreeze: disableFreeze,
IsLastOffset: isLastOffset,
PruneAncientData: pruneAncientData,
})

if err == nil {
db = n.wrapDatabase(db)
Expand Down

0 comments on commit 8b18c3d

Please sign in to comment.