downloader: improved downloading and synchronisation

* Downloader's peers keeps track of peer's previously requested hashes
  so that we don't have to re-request
* Changed `AddBlock` to be fully synchronous
This commit is contained in:
obscuren
2015-04-18 18:54:57 +02:00
parent 60613b57d1
commit c2c24b3bb4
4 changed files with 130 additions and 111 deletions

View File

@ -65,6 +65,9 @@ func (c *queue) get(p *peer, max int) *chunk {
return true
})
// remove hashes that have previously been fetched
hashes.Separate(p.requested)
// remove the fetchable hashes from hash pool
c.hashPool.Separate(hashes)
c.fetchPool.Merge(hashes)