@@ -29,6 +29,7 @@ import (
2929 "time"
3030
3131 "github.com/ethereum/go-ethereum/common"
32+ "github.com/ethereum/go-ethereum/common/mclock"
3233 "github.com/ethereum/go-ethereum/core/state"
3334 "github.com/ethereum/go-ethereum/core/types"
3435 "github.com/ethereum/go-ethereum/core/vm"
@@ -799,7 +800,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
799800 if stats .ignored > 0 {
800801 ignored = fmt .Sprintf (" (%d ignored)" , stats .ignored )
801802 }
802- 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 )
803+ 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 )
803804
804805 return 0 , nil
805806}
@@ -875,7 +876,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
875876 // faster than direct delivery and requires much less mutex
876877 // acquiring.
877878 var (
878- stats = insertStats {startTime : time .Now ()}
879+ stats = insertStats {startTime : mclock .Now ()}
879880 events = make ([]interface {}, 0 , len (chain ))
880881 coalescedLogs []* types.Log
881882 nonceChecked = make ([]bool , len (chain ))
@@ -1031,7 +1032,7 @@ type insertStats struct {
10311032 queued , processed , ignored int
10321033 usedGas uint64
10331034 lastIndex int
1034- startTime time. Time
1035+ startTime mclock. AbsTime
10351036}
10361037
10371038// statsReportLimit is the time limit during import after which we always print
@@ -1043,12 +1044,9 @@ const statsReportLimit = 8 * time.Second
10431044func (st * insertStats ) report (chain []* types.Block , index int ) {
10441045 // Fetch the timings for the batch
10451046 var (
1046- now = time .Now ()
1047- elapsed = now . Sub (st .startTime )
1047+ now = mclock .Now ()
1048+ elapsed = time . Duration ( now ) - time . Duration (st .startTime )
10481049 )
1049- if elapsed == 0 { // Yes Windows, I'm looking at you
1050- elapsed = 1
1051- }
10521050 // If we're at the last block of the batch or report period reached, log
10531051 if index == len (chain )- 1 || elapsed >= statsReportLimit {
10541052 start , end := chain [st .lastIndex ], chain [index ]
@@ -1063,7 +1061,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
10631061 } else {
10641062 hashes = fmt .Sprintf ("%x…" , end .Hash ().Bytes ()[:4 ])
10651063 }
1066- 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 )
1064+ 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 )
10671065
10681066 * st = insertStats {startTime : now , lastIndex : index }
10691067 }
0 commit comments