Skip to content

Commit

Permalink
update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Feb 25, 2022
1 parent 135d458 commit ecc0fdc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package downloader
import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum/perf"
"math/big"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ecc0fdc

Please sign in to comment.