core, triedb: polish

This commit is contained in:
Gary Rong 2025-09-06 21:18:16 +08:00
parent d16e8574bd
commit 821d7eea87
6 changed files with 6 additions and 12 deletions

View file

@ -1332,7 +1332,6 @@ func (bc *BlockChain) Stop() {
}
}
}
// Allow tracers to clean-up and release resources.
if bc.logger != nil && bc.logger.OnClose != nil {
bc.logger.OnClose()

View file

@ -285,11 +285,6 @@ func (db *CachingDB) TrieDB() *triedb.Database {
return db.triedb
}
// DiskDB returns the underlying disk database for direct access.
func (db *CachingDB) DiskDB() ethdb.KeyValueStore {
return db.disk
}
// PointCache returns the cache of evaluated curve points.
func (db *CachingDB) PointCache() *utils.PointCache {
return db.pointCache

View file

@ -186,7 +186,6 @@ func NewWithReader(root common.Hash, db Database, reader Reader) (*StateDB, erro
if db.TrieDB().IsVerkle() {
sdb.accessEvents = NewAccessEvents(db.PointCache())
}
return sdb, nil
}
@ -668,7 +667,7 @@ func (s *StateDB) CreateContract(addr common.Address) {
// Copy creates a deep, independent copy of the state.
// Snapshots of the copied state cannot be applied to the copy.
func (s *StateDB) Copy() *StateDB {
// Copy all the basic fields, init the memory ones
// Copy all the basic fields, initialize the memory ones
state := &StateDB{
db: s.db,
reader: s.reader,

View file

@ -281,7 +281,7 @@ func TestCopyObjectState(t *testing.T) {
cpy := orig.Copy()
for _, op := range cpy.mutations {
if have, want := op.applied, false; have != want {
t.Fatalf("Error in test itself, the 'aborted' flag should not be set before Commit, have %v want %v", have, want)
t.Fatalf("Error in test itself, the 'done' flag should not be set before Commit, have %v want %v", have, want)
}
}
orig.Commit(0, true, false)

View file

@ -73,7 +73,7 @@ func TestVerklePrefetcher(t *testing.T) {
state, err := New(types.EmptyRootHash, sdb)
if err != nil {
t.Fatalf("failed to init state: %v", err)
t.Fatalf("failed to initialize state: %v", err)
}
// Create an account and check if the retrieved balance is correct
addr := testrand.Address()

View file

@ -136,7 +136,8 @@ type Database struct {
stateFreezer ethdb.ResettableAncientStore // Freezer for storing state histories, nil possible in tests
stateIndexer *historyIndexer // History indexer historical state data, nil possible
lock sync.RWMutex // Lock to prevent mutations from happening at the same time
lock sync.RWMutex // Lock to prevent mutations from happening at the same time
}
// New attempts to load an already existing layer from a persistent key-value
@ -681,7 +682,7 @@ func (db *Database) StorageIterator(root common.Hash, account common.Hash, seek
return newFastStorageIterator(db, root, account, seek)
}
// SnapshotCompleted returns the snapshot root if the snapshot generation is completed.
// SnapshotCompleted returns the flag indicating if the snapshot generation is completed.
func (db *Database) SnapshotCompleted() bool {
db.lock.RLock()
wait := db.waitSync