@@ -29,6 +29,7 @@ import (
29
29
"time"
30
30
31
31
"github.com/ethereum/go-ethereum/common"
32
+ "github.com/ethereum/go-ethereum/common/mclock"
32
33
"github.com/ethereum/go-ethereum/core/state"
33
34
"github.com/ethereum/go-ethereum/core/types"
34
35
"github.com/ethereum/go-ethereum/core/vm"
@@ -799,7 +800,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
799
800
if stats .ignored > 0 {
800
801
ignored = fmt .Sprintf (" (%d ignored)" , stats .ignored )
801
802
}
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 )
803
804
804
805
return 0 , nil
805
806
}
@@ -875,7 +876,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
875
876
// faster than direct delivery and requires much less mutex
876
877
// acquiring.
877
878
var (
878
- stats = insertStats {startTime : time .Now ()}
879
+ stats = insertStats {startTime : mclock .Now ()}
879
880
events = make ([]interface {}, 0 , len (chain ))
880
881
coalescedLogs []* types.Log
881
882
nonceChecked = make ([]bool , len (chain ))
@@ -1031,7 +1032,7 @@ type insertStats struct {
1031
1032
queued , processed , ignored int
1032
1033
usedGas uint64
1033
1034
lastIndex int
1034
- startTime time. Time
1035
+ startTime mclock. AbsTime
1035
1036
}
1036
1037
1037
1038
// statsReportLimit is the time limit during import after which we always print
@@ -1043,12 +1044,9 @@ const statsReportLimit = 8 * time.Second
1043
1044
func (st * insertStats ) report (chain []* types.Block , index int ) {
1044
1045
// Fetch the timings for the batch
1045
1046
var (
1046
- now = time .Now ()
1047
- elapsed = now . Sub (st .startTime )
1047
+ now = mclock .Now ()
1048
+ elapsed = time . Duration ( now ) - time . Duration (st .startTime )
1048
1049
)
1049
- if elapsed == 0 { // Yes Windows, I'm looking at you
1050
- elapsed = 1
1051
- }
1052
1050
// If we're at the last block of the batch or report period reached, log
1053
1051
if index == len (chain )- 1 || elapsed >= statsReportLimit {
1054
1052
start , end := chain [st .lastIndex ], chain [index ]
@@ -1063,7 +1061,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
1063
1061
} else {
1064
1062
hashes = fmt .Sprintf ("%x…" , end .Hash ().Bytes ()[:4 ])
1065
1063
}
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 )
1067
1065
1068
1066
* st = insertStats {startTime : now , lastIndex : index }
1069
1067
}
0 commit comments