Commit 9e63798d authored by obscuren's avatar obscuren

core/types, eth: meassure and display propagation times

parent f8c27d71
...@@ -99,6 +99,8 @@ type Block struct { ...@@ -99,6 +99,8 @@ type Block struct {
Td *big.Int Td *big.Int
queued bool // flag for blockpool to skip TD check queued bool // flag for blockpool to skip TD check
ReceivedAt time.Time
receipts Receipts receipts Receipts
} }
......
...@@ -346,6 +346,8 @@ func (self *ProtocolManager) handleMsg(p *peer) error { ...@@ -346,6 +346,8 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if err := request.Block.ValidateFields(); err != nil { if err := request.Block.ValidateFields(); err != nil {
return errResp(ErrDecode, "block validation %v: %v", msg, err) return errResp(ErrDecode, "block validation %v: %v", msg, err)
} }
request.Block.ReceivedAt = time.Now()
hash := request.Block.Hash() hash := request.Block.Hash()
// Add the block hash as a known hash to the peer. This will later be used to determine // Add the block hash as a known hash to the peer. This will later be used to determine
// who should receive this. // who should receive this.
...@@ -419,7 +421,7 @@ func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block) ...@@ -419,7 +421,7 @@ func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block)
for _, peer := range peers { for _, peer := range peers {
peer.sendNewBlock(block) 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 // BroadcastTx will propagate the block to its connected peers. It will sort
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment