mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
parent
ad9003c41e
commit
4e234f231a
2 changed files with 17 additions and 0 deletions
|
|
@ -1161,6 +1161,10 @@ func (bc *BlockChain) Stop() {
|
||||||
bc.chainmu.Close()
|
bc.chainmu.Close()
|
||||||
bc.wg.Wait()
|
bc.wg.Wait()
|
||||||
bc.saveData()
|
bc.saveData()
|
||||||
|
// Flush the collected preimages to disk
|
||||||
|
if err := bc.stateCache.TrieDB().CommitPreimages(); err != nil {
|
||||||
|
log.Error("Failed to commit trie preimages", "err", err)
|
||||||
|
}
|
||||||
log.Info("Blockchain manager stopped")
|
log.Info("Blockchain manager stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -824,3 +824,16 @@ func (db *Database) Size() (common.StorageSize, common.StorageSize) {
|
||||||
}
|
}
|
||||||
return db.dirtiesSize + db.childrenSize + metadataSize - metarootRefs, preimageSize
|
return db.dirtiesSize + db.childrenSize + metadataSize - metarootRefs, preimageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitPreimages flushes the dangling preimages to disk. It is meant to be
|
||||||
|
// called when closing the blockchain object, so that preimages are persisted
|
||||||
|
// to the database.
|
||||||
|
func (db *Database) CommitPreimages() error {
|
||||||
|
db.lock.Lock()
|
||||||
|
defer db.lock.Unlock()
|
||||||
|
|
||||||
|
if db.preimages == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return db.preimages.commit(true)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue