diff --git a/core/blockchain.go b/core/blockchain.go index 6a07d91789..067f44d1f1 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -822,7 +822,7 @@ func (bc *BlockChain) SnapSyncCommitHead(hash common.Hash) error { // Reset the trie database with the fresh snap synced state. root := block.Root() if bc.triedb.Scheme() == rawdb.PathScheme { - if err := bc.triedb.Activate(root); err != nil { + if err := bc.triedb.Enable(root); err != nil { return err } } diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 453a29aa8d..7fed48bdb2 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -403,7 +403,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td, ttd *big.Int, // subsequent state reads, explicitly disable the trie database and state // syncer is responsible to address and correct any state missing. if d.blockchain.TrieDB().Scheme() == rawdb.PathScheme { - if err := d.blockchain.TrieDB().Deactivate(); err != nil { + if err := d.blockchain.TrieDB().Disable(); err != nil { return err } } diff --git a/trie/database.go b/trie/database.go index f37915aa6d..1e59f0908f 100644 --- a/trie/database.go +++ b/trie/database.go @@ -273,27 +273,27 @@ func (db *Database) Recoverable(root common.Hash) (bool, error) { return pdb.Recoverable(root), nil } -// Deactivate disables the database and invalidates all available state layers +// Disable deactivates the database and invalidates all available state layers // as stale to prevent access to the persistent state, which is in the syncing // stage. // // It's only supported by path-based database and will return an error for others. -func (db *Database) Deactivate() error { +func (db *Database) Disable() error { pdb, ok := db.backend.(*pathdb.Database) if !ok { return errors.New("not supported") } - return pdb.Deactivate() + return pdb.Disable() } -// Activate re-enables database and resets the state tree with the provided. -// persistent state root once the state sync is finished. -func (db *Database) Activate(root common.Hash) error { +// Enable activates database and resets the state tree with the provided persistent +// state root once the state sync is finished. +func (db *Database) Enable(root common.Hash) error { pdb, ok := db.backend.(*pathdb.Database) if !ok { return errors.New("not supported") } - return pdb.Activate(root) + return pdb.Enable(root) } // Journal commits an entire diff hierarchy to disk into a single journal entry. diff --git a/trie/triedb/pathdb/database.go b/trie/triedb/pathdb/database.go index 720d5fb083..dc64414e9b 100644 --- a/trie/triedb/pathdb/database.go +++ b/trie/triedb/pathdb/database.go @@ -182,7 +182,7 @@ func New(diskdb ethdb.Database, config *Config) *Database { } // Disable database in case node is still in the initial state sync stage. if rawdb.ReadSnapSyncStatusFlag(diskdb) == rawdb.StateSyncRunning && !db.readOnly { - if err := db.Deactivate(); err != nil { + if err := db.Disable(); err != nil { log.Crit("Failed to disable database", "err", err) // impossible to happen } } @@ -241,10 +241,10 @@ func (db *Database) Commit(root common.Hash, report bool) error { return db.tree.cap(root, 0) } -// Deactivate disables the database and invalidates all available state layers +// Disable deactivates the database and invalidates all available state layers // as stale to prevent access to the persistent state, which is in the syncing // stage. -func (db *Database) Deactivate() error { +func (db *Database) Disable() error { db.lock.Lock() defer db.lock.Unlock() @@ -268,9 +268,9 @@ func (db *Database) Deactivate() error { return nil } -// Activate re-enables database and resets the state tree with the provided. -// persistent state root once the state sync is finished. -func (db *Database) Activate(root common.Hash) error { +// Enable activates database and resets the state tree with the provided persistent +// state root once the state sync is finished. +func (db *Database) Enable(root common.Hash) error { db.lock.Lock() defer db.lock.Unlock() diff --git a/trie/triedb/pathdb/database_test.go b/trie/triedb/pathdb/database_test.go index b5b2873c65..912364f7f4 100644 --- a/trie/triedb/pathdb/database_test.go +++ b/trie/triedb/pathdb/database_test.go @@ -444,13 +444,13 @@ func TestDisable(t *testing.T) { defer tester.release() _, stored := rawdb.ReadAccountTrieNode(tester.db.diskdb, nil) - if err := tester.db.Deactivate(); err != nil { + if err := tester.db.Disable(); err != nil { t.Fatal("Failed to deactivate database") } - if err := tester.db.Activate(types.EmptyRootHash); err == nil { + if err := tester.db.Enable(types.EmptyRootHash); err == nil { t.Fatalf("Invalid activation should be rejected") } - if err := tester.db.Activate(stored); err != nil { + if err := tester.db.Enable(stored); err != nil { t.Fatal("Failed to activate database") }