mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
remove setWriter function and add writer in load function
This commit is contained in:
parent
fe6d9e1018
commit
0a8a981a58
1 changed files with 2 additions and 13 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue