aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-08-09 16:38:34 +0800
committerGitHub <noreply@github.com>2016-08-09 16:38:34 +0800
commit44ea0da2b0bc96505299c083cac44d60814a78eb (patch)
tree5da823845a7b894d20271fe968abac6a5385763e /eth/downloader/downloader.go
parent4f4e1026f50860b05a61fe4b5d53d6933f62f549 (diff)
parent1dd272080dfb49a07a87c46e18d8aeaa0fd41a08 (diff)
downloadgo-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar.gz
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar.bz2
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar.lz
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar.xz
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.tar.zst
go-tangerine-44ea0da2b0bc96505299c083cac44d60814a78eb.zip
Merge pull request #2861 from karalabe/track-peer-heads-properly
eth, eth/downloader: better remote head tracking
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r--eth/downloader/downloader.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index aee21122a..1f9ef598c 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -236,12 +236,12 @@ func (d *Downloader) Synchronising() bool {
// RegisterPeer injects a new download peer into the set of block source to be
// used for fetching hashes and blocks from.
-func (d *Downloader) RegisterPeer(id string, version int, head common.Hash,
+func (d *Downloader) RegisterPeer(id string, version int, currentHead currentHeadRetrievalFn,
getRelHeaders relativeHeaderFetcherFn, getAbsHeaders absoluteHeaderFetcherFn, getBlockBodies blockBodyFetcherFn,
getReceipts receiptFetcherFn, getNodeData stateFetcherFn) error {
glog.V(logger.Detail).Infoln("Registering peer", id)
- if err := d.peers.Register(newPeer(id, version, head, getRelHeaders, getAbsHeaders, getBlockBodies, getReceipts, getNodeData)); err != nil {
+ if err := d.peers.Register(newPeer(id, version, currentHead, getRelHeaders, getAbsHeaders, getBlockBodies, getReceipts, getNodeData)); err != nil {
glog.V(logger.Error).Infoln("Register failed:", err)
return err
}
@@ -501,7 +501,8 @@ func (d *Downloader) fetchHeight(p *peer) (*types.Header, error) {
glog.V(logger.Debug).Infof("%v: retrieving remote chain height", p)
// Request the advertised remote head block and wait for the response
- go p.getRelHeaders(p.head, 1, 0, false)
+ head, _ := p.currentHead()
+ go p.getRelHeaders(head, 1, 0, false)
timeout := time.After(d.requestTTL())
for {