diff options
Diffstat (limited to 'data/ledger.go')
-rw-r--r-- | data/ledger.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/data/ledger.go b/data/ledger.go index f5d851082..8fc03cb6e 100644 --- a/data/ledger.go +++ b/data/ledger.go @@ -325,14 +325,16 @@ func (l *Ledger) EnsureValidatedBlock(vb *ledgercore.ValidatedBlock, c agreement break } - logfn := logging.Base().Errorf + logfn := l.log.Errorf switch err.(type) { case ledgercore.BlockInLedgerError: - logfn = logging.Base().Debugf + // If the block is already in the ledger (catchup and agreement might be competing), + // reporting this as a debug message is sufficient. + logfn = l.log.Debugf + // Otherwise, the error is because the block is in the future. Error is logged. } - - logfn("could not write block %d to the ledger: %v", round, err) + logfn("data.EnsureValidatedBlock: could not write block %d to the ledger: %v", round, err) } } @@ -353,14 +355,16 @@ func (l *Ledger) EnsureBlock(block *bookkeeping.Block, c agreement.Certificate) switch err.(type) { case protocol.Error: if !protocolErrorLogged { - logging.Base().Errorf("unrecoverable protocol error detected at block %d: %v", round, err) + l.log.Errorf("data.EnsureBlock: unrecoverable protocol error detected at block %d: %v", round, err) protocolErrorLogged = true } case ledgercore.BlockInLedgerError: - logging.Base().Debugf("could not write block %d to the ledger: %v", round, err) - return // this error implies that l.LastRound() >= round + // The block is already in the ledger. Catchup and agreement could be competing + // It is sufficient to report this as a Debug message + l.log.Debugf("data.EnsureBlock: could not write block %d to the ledger: %v", round, err) + return default: - logging.Base().Errorf("could not write block %d to the ledger: %v", round, err) + l.log.Errorf("data.EnsureBlock: could not write block %d to the ledger: %v", round, err) } // If there was an error add a short delay before the next attempt. |