diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-18 21:14:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-18 21:14:12 +0800 |
commit | 8244825bbf9ca7342c052508f50a56b16c979a1e (patch) | |
tree | 03f53ddc58bafbbed99280a876929a98df3de1fd /eth/downloader/queue.go | |
parent | eef4776b5bb9d77a0dab0d9ac8da61fdbc72129f (diff) | |
download | go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar.gz go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar.bz2 go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar.lz go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar.xz go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.tar.zst go-tangerine-8244825bbf9ca7342c052508f50a56b16c979a1e.zip |
downloader: reset the queue if a peer response with an empty hash set
Diffstat (limited to 'eth/downloader/queue.go')
-rw-r--r-- | eth/downloader/queue.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 4d1aa4e93..df3bf7087 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -31,6 +31,17 @@ func newqueue() *queue { } } +func (c *queue) reset() { + c.mu.Lock() + defer c.mu.Unlock() + + c.hashPool.Clear() + c.fetchPool.Clear() + c.blockHashes.Clear() + c.blocks = nil + c.fetching = make(map[string]*chunk) +} + // reserve a `max` set of hashes for `p` peer. func (c *queue) get(p *peer, max int) *chunk { c.mu.Lock() |