eth: calculate the correct TD, only update if better

This commit is contained in:
Péter Szilágyi
2015-07-09 13:55:06 +03:00
parent a2333bcbb4
commit 4f95e2f9ec
2 changed files with 17 additions and 5 deletions

View File

@ -167,12 +167,12 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash) error {
}
// SendNewBlock propagates an entire block to a remote peer.
func (p *peer) SendNewBlock(block *types.Block) error {
func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error {
propBlockOutPacketsMeter.Mark(1)
propBlockOutTrafficMeter.Mark(block.Size().Int64())
p.knownBlocks.Add(block.Hash())
return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, block.Td})
return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, td})
}
// RequestHashes fetches a batch of hashes from a peer, starting at from, going