Skip to content

Commit a50c006

Browse files
authored
core: make tx journal check and open atomic (#25530)
* core: reduce system call about `os` * avoid deprecated method
1 parent 6da5c16 commit a50c006

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/tx_journal.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package core
1919
import (
2020
"errors"
2121
"io"
22+
"io/fs"
2223
"os"
2324

2425
"github.com/ethereum/go-ethereum/common"
@@ -57,12 +58,12 @@ func newTxJournal(path string) *txJournal {
5758
// load parses a transaction journal dump from disk, loading its contents into
5859
// the specified pool.
5960
func (journal *txJournal) load(add func([]*types.Transaction) []error) error {
60-
// Skip the parsing if the journal file doesn't exist at all
61-
if !common.FileExist(journal.path) {
62-
return nil
63-
}
6461
// Open the journal for loading any past transactions
6562
input, err := os.Open(journal.path)
63+
if errors.Is(err, fs.ErrNotExist) {
64+
// Skip the parsing if the journal file doesn't exist at all
65+
return nil
66+
}
6667
if err != nil {
6768
return err
6869
}

0 commit comments

Comments
 (0)