diff options
Diffstat (limited to 'block_pool.go')
-rw-r--r-- | block_pool.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/block_pool.go b/block_pool.go index 52f2f4f86..090871fd3 100644 --- a/block_pool.go +++ b/block_pool.go @@ -200,7 +200,7 @@ func (self *BlockPool) DistributeHashes() { } else if lastFetchFailed || item.peer == nil { // Find a suitable, available peer eachPeer(self.eth.peers, func(p *Peer, v *list.Element) { - if peer == nil && len(dist[p]) < amount/peerLen { + if peer == nil && len(dist[p]) < amount/peerLen && p.statusKnown { peer = p } }) @@ -316,21 +316,24 @@ out: if len(blocks) > 0 { chainManager := self.eth.ChainManager() // Test and import - chain := chain.NewChain(blocks) - _, err := chainManager.TestChain(chain) - if err != nil { + bchain := chain.NewChain(blocks) + _, err := chainManager.TestChain(bchain) + if err != nil && !chain.IsTDError(err) { poollogger.Debugln(err) self.Reset() - poollogger.Debugf("Punishing peer for supplying bad chain (%v)\n", self.peer.conn.RemoteAddr()) + if self.peer != nil && self.peer.conn != nil { + poollogger.Debugf("Punishing peer for supplying bad chain (%v)\n", self.peer.conn.RemoteAddr()) + } + // This peer gave us bad hashes and made us fetch a bad chain, therefor he shall be punished. self.eth.BlacklistPeer(self.peer) self.peer.StopWithReason(DiscBadPeer) self.td = ethutil.Big0 self.peer = nil } else { - chainManager.InsertChain(chain) + chainManager.InsertChain(bchain) for _, block := range blocks { self.Remove(block.Hash()) } |