diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-12 19:33:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-12 19:36:01 +0800 |
commit | 7dcb9825c3a3afe1a287ad544a5ad0500c0027a7 (patch) | |
tree | 98d7933f1e426b766ffeb33b138e7828d9189616 /eth/downloader/downloader.go | |
parent | 6efa8db8887c70679aedeaec44411f886976d2e1 (diff) | |
download | go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar.gz go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar.bz2 go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar.lz go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar.xz go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.tar.zst go-tangerine-7dcb9825c3a3afe1a287ad544a5ad0500c0027a7.zip |
downloader: return an error for peer.fetch and return chunk to queue
If a peer was somehow already fetching and somehow managed to end up in
the `available` pool it should return it's work.
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r-- | eth/downloader/downloader.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 1b9b7d01b..206c4cc7e 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -268,8 +268,14 @@ out: chunk := d.queue.get(peer, maxBlockFetch) if chunk != nil { //fmt.Println("fetching for", peer.id) - // Fetch the chunk. - peer.fetch(chunk) + // Fetch the chunk and check for error. If the peer was somehow + // already fetching a chunk due to a bug, it will be returned to + // the queue + if err := peer.fetch(chunk); err != nil { + // log for tracing + glog.V(logger.Debug).Infof("peer %s received double work (state = %v)\n", peer.id, peer.state) + d.queue.put(chunk.hashes) + } } } atomic.StoreInt32(&d.downloadingBlocks, 1) |