From a50c006b49ef0411e3389b801f5b4594c72fe3b3 Mon Sep 17 00:00:00 2001 From: Seungbae Yu Date: Wed, 17 Aug 2022 20:16:18 +0900 Subject: [PATCH] core: make tx journal check and open atomic (#25530) * core: reduce system call about `os` * avoid deprecated method --- core/tx_journal.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/tx_journal.go b/core/tx_journal.go index 5453ee1916..62344f5646 100644 --- a/core/tx_journal.go +++ b/core/tx_journal.go @@ -19,6 +19,7 @@ package core import ( "errors" "io" + "io/fs" "os" "github.com/ethereum/go-ethereum/common" @@ -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 }