From 677836cbee1105043335c672b41dc4402e98c227 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 2 Oct 2014 17:35:38 +0200 Subject: Kick off bad peers on bad chains and improved catch up on diverted chain --- peer.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'peer.go') diff --git a/peer.go b/peer.go index 2806e8a11..763658dd5 100644 --- a/peer.go +++ b/peer.go @@ -202,7 +202,7 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { go func() { conn, err := p.Connect(addr) if err != nil { - peerlogger.Debugln("Connection to peer failed. Giving up.", err) + //peerlogger.Debugln("Connection to peer failed. Giving up.", err) p.Stop() return } @@ -517,7 +517,9 @@ func (p *Peer) HandleInbound() { } if !foundCommonHash && msg.Data.Len() != 0 { - p.FetchHashes() + if !p.FetchHashes() { + p.doneFetchingHashes = true + } } else { peerlogger.Infof("Found common hash (%x...)\n", p.lastReceivedHash[0:4]) p.doneFetchingHashes = true @@ -553,9 +555,9 @@ func (self *Peer) FetchBlocks(hashes [][]byte) { } } -func (self *Peer) FetchHashes() { +func (self *Peer) FetchHashes() bool { blockPool := self.ethereum.blockPool - blockPool.FetchHashes(self) + return blockPool.FetchHashes(self) /* if self.td.Cmp(self.ethereum.HighestTDPeer()) >= 0 { @@ -718,10 +720,7 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) { // Compare the total TD with the blockchain TD. If remote is higher // fetch hashes from highest TD node. - if self.td.Cmp(self.ethereum.BlockChain().TD) > 0 { - self.ethereum.blockPool.AddHash(self.lastReceivedHash, self) - self.FetchHashes() - } + self.FetchHashes() ethlogger.Infof("Peer is [eth] capable. (TD = %v ~ %x) %d / %d", self.td, self.bestHash, protoVersion, netVersion) -- cgit