From e1d4db41552b7ac033e669f06b5d9441d4e7b7d2 Mon Sep 17 00:00:00 2001 From: dbadoy4874 Date: Tue, 16 Aug 2022 11:09:25 +0900 Subject: [PATCH 1/2] core: reduce system call about `os` --- core/tx_journal.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/tx_journal.go b/core/tx_journal.go index 5453ee191658..dc7a3c04b390 100644 --- a/core/tx_journal.go +++ b/core/tx_journal.go @@ -57,12 +57,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 os.IsNotExist(err) { + // Skip the parsing if the journal file doesn't exist at all + return nil + } if err != nil { return err } From d576ccbfc81a0d946273d479aa05fe9fdcc748b4 Mon Sep 17 00:00:00 2001 From: dbadoy4874 Date: Tue, 16 Aug 2022 22:49:06 +0900 Subject: [PATCH 2/2] avoid deprecated method --- core/tx_journal.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/tx_journal.go b/core/tx_journal.go index dc7a3c04b390..62344f564676 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" @@ -59,7 +60,7 @@ func newTxJournal(path string) *txJournal { func (journal *txJournal) load(add func([]*types.Transaction) []error) error { // Open the journal for loading any past transactions input, err := os.Open(journal.path) - if os.IsNotExist(err) { + if errors.Is(err, fs.ErrNotExist) { // Skip the parsing if the journal file doesn't exist at all return nil }