diff --git a/core/blockchain.go b/core/blockchain.go index 183ba03d9c..e29149f2ac 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1778,7 +1778,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness // Fire a single chain head event if we've progressed the chain defer func() { if lastCanon != nil && bc.CurrentBlock().Hash() == lastCanon.Hash() { - bc.chainHeadFeed.Send(ChainHeadEvent{Header: lastCanon.Header(), Time: uint64(mclock.Now().Sub(stats.startTime))}) + bc.chainHeadFeed.Send(ChainHeadEvent{Header: lastCanon.Header(), ProcessingTime: mclock.Now().Sub(stats.startTime)}) } }() // Start the parallel header verifier diff --git a/core/events.go b/core/events.go index 5c72a50f75..8e51058b58 100644 --- a/core/events.go +++ b/core/events.go @@ -17,6 +17,8 @@ package core import ( + "time" + "github.com/ethereum/go-ethereum/core/types" ) @@ -33,6 +35,6 @@ type ChainEvent struct { } type ChainHeadEvent struct { - Header *types.Header - Time uint64 + Header *types.Header + ProcessingTime time.Duration } diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 8510bb5ba9..b5e8b630e3 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -604,7 +604,7 @@ func (s uncleStats) MarshalJSON() ([]byte, error) { // reportBlock retrieves the current chain head and reports it to the stats server. func (s *Service) reportBlock(conn *connWrapper, header *core.ChainHeadEvent) error { // Gather the block details from the header or block chain - details := s.assembleBlockStats(header.Header, header.Time) + details := s.assembleBlockStats(header.Header, header.ProcessingTime) // Short circuit if the block detail is not available. if details == nil { @@ -625,7 +625,7 @@ func (s *Service) reportBlock(conn *connWrapper, header *core.ChainHeadEvent) er // assembleBlockStats retrieves any required metadata to report a single block // and assembles the block stats. If block is nil, the current head is processed. -func (s *Service) assembleBlockStats(header *types.Header, time uint64) *blockStats { +func (s *Service) assembleBlockStats(header *types.Header, processingTime time.Duration) *blockStats { // Gather the block infos from the local blockchain var ( txs []txStats @@ -672,7 +672,7 @@ func (s *Service) assembleBlockStats(header *types.Header, time uint64) *blockSt TxHash: header.TxHash, Root: header.Root, Uncles: uncles, - ProcessingTime: time, + ProcessingTime: uint64(processingTime), } }