core, eth, trie: rename functions

This commit is contained in:
Gary Rong 2023-09-27 19:08:12 +08:00
parent c5890605b3
commit 470cd6098e
5 changed files with 18 additions and 18 deletions

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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.

View file

@ -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()

View file

@ -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")
}