aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-16 08:16:33 +0800
committerobscuren <geffobscura@gmail.com>2015-04-16 08:16:33 +0800
commit205378016fc342a9ee683b3d040b3e7d0e2ebb51 (patch)
tree4eb81058b47994d177afd14c3a157063c703f445 /eth/downloader/downloader.go
parenteda10c731758217f099bf4a4e232bdb3dca1e478 (diff)
downloaddexon-205378016fc342a9ee683b3d040b3e7d0e2ebb51.tar.gz
dexon-205378016fc342a9ee683b3d040b3e7d0e2ebb51.tar.zst
dexon-205378016fc342a9ee683b3d040b3e7d0e2ebb51.zip
downloader: added demotion / promotion in prep. for rep. system
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r--eth/downloader/downloader.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 56671dc2e..91cc65249 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -245,6 +245,7 @@ out:
for {
select {
case blockPack := <-d.blockCh:
+ d.peers[blockPack.peerId].promote()
d.queue.deliver(blockPack.peerId, blockPack.blocks)
d.peers.setState(blockPack.peerId, idleState)
case <-ticker.C:
@@ -310,6 +311,9 @@ out:
// 2) Measure their speed;
// 3) Amount and availability.
d.queue.deliver(pid, nil)
+ if peer := p.peers[pid]; peer != nil {
+ peer.demote()
+ }
}
}
@@ -343,6 +347,7 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
peer.td = td
peer.recentHash = block.Hash()
peer.mu.Unlock()
+ peer.promote()
glog.V(logger.Detail).Infoln("Inserting new block from:", id)
d.queue.addBlock(id, block, td)