From ecc0fdc5c234f5fc6fcbc6c8797a094ae6113dc1 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 25 Feb 2022 18:24:25 +0800 Subject: [PATCH] update logs --- core/blockchain.go | 2 -- eth/downloader/downloader.go | 3 +++ eth/protocols/eth/peer.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index a5fe6d6056..021c75b5fa 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1902,8 +1902,6 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) { return 0, fmt.Errorf("non contiguous insert: item %d is #%d [%x..], item %d is #%d [%x..] (parent [%x..])", i-1, prev.NumberU64(), prev.Hash().Bytes()[:4], i, block.NumberU64(), block.Hash().Bytes()[:4], block.ParentHash().Bytes()[:4]) } - // match P2P_SEND logs to estimate the p2p propagation time - perf.RecordMPLogs(nil, "P2P_RECEIVE", "block", block.Number(), "hash", block.Hash(), "time", time.Now().UnixNano()) } // Pre-checks passed, start the full block imports bc.wg.Add(1) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index e1225e7a1c..3c11af9a82 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -20,6 +20,7 @@ package downloader import ( "errors" "fmt" + "github.com/ethereum/go-ethereum/perf" "math/big" "sync" "sync/atomic" @@ -1801,6 +1802,8 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error { blocks := make([]*types.Block, len(results)) for i, result := range results { blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.Transactions, result.Uncles) + // match P2P_SEND logs to estimate the p2p propagation time + perf.RecordMPLogs(nil, "P2P_RECEIVE", "peer", result.pid, "block", blocks[i].Number(), "hash", blocks[i].Hash(), "time", time.Now().UnixNano()) } if index, err := d.blockchain.InsertChain(blocks); err != nil { if index < len(results) { diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index 338b89248e..7d0b626843 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -357,7 +357,7 @@ func (p *Peer) SendNewBlock(block *types.Block, td *big.Int) error { TD: td, }) perf.RecordMPMetrics(perf.MpPropagationSend, start) - perf.RecordMPLogs(p.Log(), "P2P_SEND", "peer", p.id, "block", block.NumberU64(), "hash", block.Hash(), "time", time.Now().UnixNano()) + perf.RecordMPLogs(nil, "P2P_SEND", "peer", p.id, "block", block.NumberU64(), "hash", block.Hash(), "time", time.Now().UnixNano()) return err }