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 blakehhuynh committed Oct 7, 2022
1 parent 420e4f8 commit 2a4e166
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/tx_journal.go
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 2a4e166

Please sign in to comment.