aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-30 18:38:16 +0800
committerobscuren <geffobscura@gmail.com>2015-04-30 18:38:16 +0800
commit9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0 (patch)
treed7c149a6104303c31c3557c234862bfc3ee866c2 /eth/downloader
parent3fef60190384106af390dd23a65384b9cc6e4a28 (diff)
downloaddexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar.gz
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar.bz2
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar.lz
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar.xz
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.tar.zst
dexon-9b6e8f6195da1d52ba35295d9d8a3a9f24ec30b0.zip
eth, eth/downloader: remove bad peers from peer set
Peers in the eth protocol handler are now being ignored for catch up.
Diffstat (limited to 'eth/downloader')
-rw-r--r--eth/downloader/downloader.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 4cd927fd5..a48b60716 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -30,7 +30,7 @@ var (
errLowTd = errors.New("peer's TD is too low")
errBusy = errors.New("busy")
errUnknownPeer = errors.New("peer's unknown or unhealthy")
- errBadPeer = errors.New("action from bad peer ignored")
+ ErrBadPeer = errors.New("action from bad peer ignored")
errTimeout = errors.New("timeout")
errEmptyHashSet = errors.New("empty hash set by peer")
errPeersUnavailable = errors.New("no peers available or all peers tried for block download process")
@@ -376,7 +376,7 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) error
// and add the block. Otherwise just ignore it
if peer == nil {
glog.V(logger.Detail).Infof("Ignored block from bad peer %s\n", id)
- return errBadPeer
+ return ErrBadPeer
}
peer.mu.Lock()
@@ -422,10 +422,7 @@ func (d *Downloader) process(peer *peer) error {
return nil
}
- var (
- blocks = d.queue.blocks
- err error
- )
+ var blocks = d.queue.blocks
glog.V(logger.Debug).Infof("Inserting chain with %d blocks (#%v - #%v)\n", len(blocks), blocks[0].Number(), blocks[len(blocks)-1].Number())
// Loop untill we're out of blocks
@@ -435,7 +432,7 @@ func (d *Downloader) process(peer *peer) error {
// processing and start requesting the `block.hash` so that it's parent and
// grandparents can be requested and queued.
var i int
- i, err = d.insertChain(blocks[:max])
+ i, err := d.insertChain(blocks[:max])
if err != nil && core.IsParentErr(err) {
// Ignore the missing blocks. Handler should take care of anything that's missing.
glog.V(logger.Debug).Infof("Ignored block with missing parent (%d)\n", i)
@@ -447,8 +444,9 @@ func (d *Downloader) process(peer *peer) error {
d.UnregisterPeer(d.activePeer)
// Reset chain completely. This needs much, much improvement.
// instead: check all blocks leading down to this block false block and remove it
- blocks = nil
- break
+ d.queue.blocks = nil
+
+ return ErrBadPeer
}
blocks = blocks[max:]
}
@@ -459,7 +457,7 @@ func (d *Downloader) process(peer *peer) error {
} else {
d.queue.blocks = blocks
}
- return err
+ return nil
}
func (d *Downloader) isFetchingHashes() bool {