Skip to content

Commit

Permalink
core: make tx journal check and open atomic (ethereum#25530)
Browse files Browse the repository at this point in the history
* core: reduce system call about `os`

* avoid deprecated method
  • Loading branch information
dbadoy authored and cp-wjhan committed Oct 20, 2023
1 parent 5d9295e commit b96eeb3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/tx_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package core
import (
"errors"
"io"
"io/fs"
"os"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -57,12 +58,12 @@ func newTxJournal(path string) *txJournal {
// load parses a transaction journal dump from disk, loading its contents into
// the specified pool.
func (journal *txJournal) load(add func([]*types.Transaction) []error) error {
// Skip the parsing if the journal file doesn't exist at all
if !common.FileExist(journal.path) {
return nil
}
// Open the journal for loading any past transactions
input, err := os.Open(journal.path)
if errors.Is(err, fs.ErrNotExist) {
// Skip the parsing if the journal file doesn't exist at all
return nil
}
if err != nil {
return err
}
Expand Down

0 comments on commit b96eeb3

Please sign in to comment.