eth, trie: address comments

This commit is contained in:
Gary Rong 2023-09-26 18:13:41 +08:00
parent 505ece695a
commit bcd5792ca4
2 changed files with 8 additions and 3 deletions

View file

@ -403,7 +403,9 @@ 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 {
d.blockchain.TrieDB().Deactivate()
if err := d.blockchain.TrieDB().Deactivate(); err != nil {
return err
}
}
// Snap sync uses the snapshot namespace to store potentially flaky data until
// sync completely heals and finishes. Pause snapshot maintenance in the mean-

View file

@ -182,7 +182,9 @@ 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 {
db.Deactivate()
if err := db.Deactivate(); err != nil {
log.Crit("Failed to disable database", "err", err) // impossible to happen
}
}
log.Warn("Path-based state scheme is an experimental feature")
return db
@ -252,6 +254,7 @@ func (db *Database) Deactivate() error {
}
// Prevent duplicated disable operation.
if db.waitSync {
log.Error("Reject duplicated disable operation")
return nil
}
db.waitSync = true
@ -279,7 +282,7 @@ func (db *Database) Activate(root common.Hash) error {
root = types.TrieRootHash(root)
_, stored := rawdb.ReadAccountTrieNode(db.diskdb, nil)
if stored != root {
return fmt.Errorf("state is mismatched, stored: %x, target: %x", stored, root)
return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root)
}
// Drop the stale state journal in persistent database and
// reset the persistent state id back to zero.