diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-30 01:55:30 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-30 01:55:30 +0800 |
commit | 9e63798d0362a27b3ef45345d93f4a01c3349516 (patch) | |
tree | a018d38a3cdad75246c0cf4845e3cc0e6c17a0fd | |
parent | f8c27d7159c3f93f0ca05ab1df86cca98d86e52e (diff) | |
download | go-tangerine-9e63798d0362a27b3ef45345d93f4a01c3349516.tar.gz go-tangerine-9e63798d0362a27b3ef45345d93f4a01c3349516.tar.zst go-tangerine-9e63798d0362a27b3ef45345d93f4a01c3349516.zip |
core/types, eth: meassure and display propagation times
-rw-r--r-- | core/types/block.go | 2 | ||||
-rw-r--r-- | eth/handler.go | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/core/types/block.go b/core/types/block.go index 19cf49c12..c93452fa7 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -99,6 +99,8 @@ type Block struct { Td *big.Int queued bool // flag for blockpool to skip TD check + ReceivedAt time.Time + receipts Receipts } diff --git a/eth/handler.go b/eth/handler.go index 2dd4c74db..f7610e9e3 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -346,6 +346,8 @@ func (self *ProtocolManager) handleMsg(p *peer) error { if err := request.Block.ValidateFields(); err != nil { return errResp(ErrDecode, "block validation %v: %v", msg, err) } + request.Block.ReceivedAt = time.Now() + hash := request.Block.Hash() // Add the block hash as a known hash to the peer. This will later be used to determine // who should receive this. @@ -419,7 +421,7 @@ func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block) for _, peer := range peers { peer.sendNewBlock(block) } - glog.V(logger.Detail).Infoln("broadcast block to", len(peers), "peers") + glog.V(logger.Detail).Infoln("broadcast block to", len(peers), "peers. Total propagation time:", time.Since(block.ReceivedAt)) } // BroadcastTx will propagate the block to its connected peers. It will sort |