aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-11 20:53:54 +0800
committerGitHub <noreply@github.com>2017-01-11 20:53:54 +0800
commit218ec6c0856caaff70df8e318e035c4ed8c97820 (patch)
treee9c6cb015b19a0010c7ab60bae6520fb66663a44
parentd30d7800e01def081a5f2e37846f17ae0d5c6910 (diff)
parent21f1370d2a1d7199e65697c7b5d56a8253b78871 (diff)
downloadgo-tangerine-218ec6c0856caaff70df8e318e035c4ed8c97820.tar.gz
go-tangerine-218ec6c0856caaff70df8e318e035c4ed8c97820.tar.zst
go-tangerine-218ec6c0856caaff70df8e318e035c4ed8c97820.zip
Merge pull request #3551 from fjl/core-import-log-align
core: improve import log alignment
-rw-r--r--core/blockchain.go16
-rw-r--r--core/headerchain.go2
2 files changed, 8 insertions, 10 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 8eb7de982..6462c17fa 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -29,6 +29,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -799,7 +800,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
if stats.ignored > 0 {
ignored = fmt.Sprintf(" (%d ignored)", stats.ignored)
}
- glog.V(logger.Info).Infof("imported %d receipts in %9v. #%d [%x… / %x…]%s", stats.processed, common.PrettyDuration(time.Since(start)), last.Number(), first.Hash().Bytes()[:4], last.Hash().Bytes()[:4], ignored)
+ glog.V(logger.Info).Infof("imported %4d receipts in %9v. #%d [%x… / %x…]%s", stats.processed, common.PrettyDuration(time.Since(start)), last.Number(), first.Hash().Bytes()[:4], last.Hash().Bytes()[:4], ignored)
return 0, nil
}
@@ -875,7 +876,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
// faster than direct delivery and requires much less mutex
// acquiring.
var (
- stats = insertStats{startTime: time.Now()}
+ stats = insertStats{startTime: mclock.Now()}
events = make([]interface{}, 0, len(chain))
coalescedLogs []*types.Log
nonceChecked = make([]bool, len(chain))
@@ -1031,7 +1032,7 @@ type insertStats struct {
queued, processed, ignored int
usedGas uint64
lastIndex int
- startTime time.Time
+ startTime mclock.AbsTime
}
// statsReportLimit is the time limit during import after which we always print
@@ -1043,12 +1044,9 @@ const statsReportLimit = 8 * time.Second
func (st *insertStats) report(chain []*types.Block, index int) {
// Fetch the timings for the batch
var (
- now = time.Now()
- elapsed = now.Sub(st.startTime)
+ now = mclock.Now()
+ elapsed = time.Duration(now) - time.Duration(st.startTime)
)
- if elapsed == 0 { // Yes Windows, I'm looking at you
- elapsed = 1
- }
// If we're at the last block of the batch or report period reached, log
if index == len(chain)-1 || elapsed >= statsReportLimit {
start, end := chain[st.lastIndex], chain[index]
@@ -1063,7 +1061,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
} else {
hashes = fmt.Sprintf("%x…", end.Hash().Bytes()[:4])
}
- glog.Infof("imported %d blocks, %5d txs (%7.3f Mg) in %9v (%6.3f Mg/s). #%v [%s]%s", st.processed, txcount, float64(st.usedGas)/1000000, common.PrettyDuration(elapsed), float64(st.usedGas)*1000/float64(elapsed), end.Number(), hashes, extra)
+ glog.Infof("imported %4d blocks, %5d txs (%7.3f Mg) in %9v (%6.3f Mg/s). #%v [%s]%s", st.processed, txcount, float64(st.usedGas)/1000000, common.PrettyDuration(elapsed), float64(st.usedGas)*1000/float64(elapsed), end.Number(), hashes, extra)
*st = insertStats{startTime: now, lastIndex: index}
}
diff --git a/core/headerchain.go b/core/headerchain.go
index ca630a4f7..1dc189323 100644
--- a/core/headerchain.go
+++ b/core/headerchain.go
@@ -339,7 +339,7 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, checkFreq int, w
if stats.ignored > 0 {
ignored = fmt.Sprintf(" (%d ignored)", stats.ignored)
}
- glog.V(logger.Info).Infof("imported %d headers%s in %9v. #%v [%x… / %x…]", stats.processed, ignored, common.PrettyDuration(time.Since(start)), last.Number, first.Hash().Bytes()[:4], last.Hash().Bytes()[:4])
+ glog.V(logger.Info).Infof("imported %4d headers%s in %9v. #%v [%x… / %x…]", stats.processed, ignored, common.PrettyDuration(time.Since(start)), last.Number, first.Hash().Bytes()[:4], last.Hash().Bytes()[:4])
return 0, nil
}