aboutsummaryrefslogtreecommitdiffstats
path: root/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-02 23:35:38 +0800
committerobscuren <geffobscura@gmail.com>2014-10-02 23:35:38 +0800
commit677836cbee1105043335c672b41dc4402e98c227 (patch)
tree365b05bbd446f36078790445dc4154ceaf577b0b /peer.go
parenta75c92000fab997a41479c8f92e62f6b0d3f3434 (diff)
downloaddexon-677836cbee1105043335c672b41dc4402e98c227.tar
dexon-677836cbee1105043335c672b41dc4402e98c227.tar.gz
dexon-677836cbee1105043335c672b41dc4402e98c227.tar.bz2
dexon-677836cbee1105043335c672b41dc4402e98c227.tar.lz
dexon-677836cbee1105043335c672b41dc4402e98c227.tar.xz
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.go15
1 files changed, 7 insertions, 8 deletions
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)