downloader: moved chunk ignoring. Fixes issue with catching up

This commit is contained in:
obscuren
2015-04-19 13:30:34 +02:00
parent 4340996572
commit c58918c84a
4 changed files with 44 additions and 31 deletions

View File

@ -71,7 +71,7 @@ type peer struct {
td *big.Int
recentHash common.Hash
requested *set.Set
ignored *set.Set
getHashes hashFetcherFn
getBlocks blockFetcherFn
@ -86,7 +86,7 @@ func newPeer(id string, td *big.Int, hash common.Hash, getHashes hashFetcherFn,
getHashes: getHashes,
getBlocks: getBlocks,
state: idleState,
requested: set.New(),
ignored: set.New(),
}
}
@ -99,8 +99,6 @@ func (p *peer) fetch(chunk *chunk) error {
return errors.New("peer already fetching chunk")
}
p.requested.Merge(chunk.hashes)
// set working state
p.state = workingState
// convert the set to a fetchable slice
@ -137,5 +135,5 @@ func (p *peer) demote() {
func (p *peer) reset() {
p.state = idleState
p.requested.Clear()
p.ignored.Clear()
}