downloader: reset the queue if a peer response with an empty hash set

This commit is contained in:
obscuren
2015-04-18 15:14:12 +02:00
parent eef4776b5b
commit 8244825bbf
3 changed files with 37 additions and 15 deletions

View File

@ -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()