Skip to content

Commit

Permalink
core: fix DeleteTrieJournal params
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjunLi committed Apr 11, 2024
1 parent 8d8c061 commit af15ebf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions triedb/pathdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (db *Database) Enable(root common.Hash) error {
// Drop the stale state journal in persistent database and
// reset the persistent state id back to zero.
batch := db.diskdb.NewBatch()
db.DeleteTrieJournal()
db.DeleteTrieJournal(batch)
rawdb.WritePersistentStateID(batch, 0)
if err := batch.Write(); err != nil {
return err
Expand Down Expand Up @@ -382,7 +382,7 @@ func (db *Database) Recover(root common.Hash, loader triestate.TrieLoader) error
// disk layer won't be accessible from outside.
db.tree.reset(dl)
}
db.DeleteTrieJournal()
db.DeleteTrieJournal(db.diskdb)
_, err := truncateFromHead(db.diskdb, db.freezer, dl.stateID())
if err != nil {
return err
Expand Down Expand Up @@ -527,10 +527,10 @@ func (db *Database) GetAllRooHash() [][]string {
return data
}

func (db *Database) DeleteTrieJournal() error {
func (db *Database) DeleteTrieJournal(writer ethdb.KeyValueWriter) error {
filePath := db.config.JournalFilePath
if len(filePath) == 0 {
rawdb.DeleteTrieJournal(db.diskdb)
rawdb.DeleteTrieJournal(writer)
} else {
_, err := os.Stat(filePath)
if os.IsNotExist(err) {
Expand Down
4 changes: 2 additions & 2 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type JournalFileWriter struct {
type JournalFileReader struct {
file *os.File
}

type JournalKVWriter struct {
journalBuf bytes.Buffer
diskdb ethdb.Database
Expand Down Expand Up @@ -563,7 +564,7 @@ func (db *Database) Journal(root common.Hash) error {
return errDatabaseReadOnly
}
// Firstly write out the metadata of journal
db.DeleteTrieJournal()
db.DeleteTrieJournal(db.diskdb)
journal := newJournalWriter(db.config.JournalFilePath, db.diskdb)
defer journal.Close()

Expand All @@ -584,7 +585,6 @@ func (db *Database) Journal(root common.Hash) error {
if err := l.journal(journal); err != nil {
return err
}

// Store the journal into the database and return
journalSize := journal.Size()

Expand Down

0 comments on commit af15ebf

Please sign in to comment.