From 55d88440eb5cbbd31950bdf664b50b5456372ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Tue, 14 Jul 2020 17:12:00 +0100 Subject: [PATCH] refine block timing log statements. --- miner/miner.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index 8c46be675..a305f9b74 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -170,14 +170,18 @@ func (m *Miner) mine(ctx context.Context) { if b != nil { btime := time.Unix(int64(b.Header.Timestamp), 0) - if build.Clock.Now().Before(btime) { + now := build.Clock.Now() + switch { + case btime == now: + // block timestamp is perfectly aligned with time. + case btime.After(now): if !m.niceSleep(build.Clock.Until(btime)) { log.Warnf("received interrupt while waiting to broadcast block, will shutdown after block is sent out") build.Clock.Sleep(build.Clock.Until(btime)) } - } else { - log.Warnw("mined block in the past", "block-time", btime, - "time", build.Clock.Now(), "duration", build.Clock.Since(btime)) + default: + log.Warnw("mined block in the past", + "block-time", btime, "time", build.Clock.Now(), "difference", build.Clock.Since(btime)) } // TODO: should do better 'anti slash' protection here