diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-02 23:35:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-02 23:35:38 +0800 |
commit | 677836cbee1105043335c672b41dc4402e98c227 (patch) | |
tree | 365b05bbd446f36078790445dc4154ceaf577b0b /peer.go | |
parent | a75c92000fab997a41479c8f92e62f6b0d3f3434 (diff) | |
download | dexon-677836cbee1105043335c672b41dc4402e98c227.tar.gz dexon-677836cbee1105043335c672b41dc4402e98c227.tar.zst dexon-677836cbee1105043335c672b41dc4402e98c227.zip |
Kick off bad peers on bad chains and improved catch up on diverted chain
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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) |