Proper new block

This commit is contained in:
obscuren 2014-10-08 12:33:33 +02:00
parent 4de3ad1712
commit bd7aca76e1
1 changed files with 9 additions and 1 deletions

10
peer.go
View File

@ -539,7 +539,15 @@ func (p *Peer) HandleInbound() {
p.lastBlockReceived = time.Now()
}
case ethwire.MsgNewBlockTy:
p.ethereum.blockPool.AddNew(ethchain.NewBlockFromRlpValue(msg.Data), p)
var (
blockPool = p.ethereum.blockPool
block = ethchain.NewBlockFromRlpValue(msg.Data.Get(0))
td = msg.Data.Get(1).BigInt()
)
if td.Cmp(blockPool.td) > 0 {
p.ethereum.blockPool.AddNew(block, p)
}
}
}