From 0a8a981a58466ccfa9275fe75739b77ad96069f8 Mon Sep 17 00:00:00 2001 From: Kyrin Date: Thu, 16 Oct 2025 23:25:56 +0800 Subject: [PATCH] remove setWriter function and add writer in load function --- core/txpool/locals/journal.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/core/txpool/locals/journal.go b/core/txpool/locals/journal.go index 0b9870e094..7b89693495 100644 --- a/core/txpool/locals/journal.go +++ b/core/txpool/locals/journal.go @@ -71,7 +71,6 @@ func (journal *journal) load(add func([]*types.Transaction) []error) error { // Temporarily discard any journal additions (don't double add on load) journal.writer = new(devNull) - defer func() { journal.writer = nil }() // Inject all transactions from the journal into the pool stream := rlp.NewStream(input, 0) @@ -114,17 +113,6 @@ func (journal *journal) load(add func([]*types.Transaction) []error) error { } log.Info("Loaded local transaction journal", "transactions", total, "dropped", dropped) - return failure -} - -// setWriter opens the journal file for writing new transactions. -func (journal *journal) setWriter() error { - // Close the current writer if any - if journal.writer != nil { - journal.writer.Close() - journal.writer = nil - } - // Open the journal file for appending // Use O_APPEND to ensure we always write to the end of the file sink, err := os.OpenFile(journal.path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) @@ -132,7 +120,8 @@ func (journal *journal) setWriter() error { return err } journal.writer = sink - return nil + + return failure } // insert adds the specified transaction to the local disk journal.