diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-20 19:31:29 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-10-20 19:42:20 +0800 |
commit | 0af1ab0c86975201349d92e0943485c3534d8c8c (patch) | |
tree | f21465975f55507e85f8a3cebc7440371b266c30 /core/tx_journal.go | |
parent | 65738c1eb37c789294124cc9b4bbe6d55d50a77f (diff) | |
download | dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar.gz dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar.bz2 dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar.lz dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar.xz dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.tar.zst dexon-0af1ab0c86975201349d92e0943485c3534d8c8c.zip |
core: avoid warning when loading the transaction journal
Diffstat (limited to 'core/tx_journal.go')
-rw-r--r-- | core/tx_journal.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/tx_journal.go b/core/tx_journal.go index 94a9ff9b8..3fd8ece49 100644 --- a/core/tx_journal.go +++ b/core/tx_journal.go @@ -31,6 +31,15 @@ import ( // into the journal, but no such file is currently open. var errNoActiveJournal = errors.New("no active journal") +// devNull is a WriteCloser that just discards anything written into it. Its +// goal is to allow the transaction journal to write into a fake journal when +// loading transactions on startup without printing warnings due to no file +// being readt for write. +type devNull struct{} + +func (*devNull) Write(p []byte) (n int, err error) { return len(p), nil } +func (*devNull) Close() error { return nil } + // txJournal is a rotating log of transactions with the aim of storing locally // created transactions to allow non-executed ones to survive node restarts. type txJournal struct { @@ -59,6 +68,10 @@ func (journal *txJournal) load(add func(*types.Transaction) error) error { } defer input.Close() + // Temporarilly 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) total, dropped := 0, 0 |