simplification of Fetchers (#1344)

This commit is contained in:
Anton Evangelatov
2019-06-17 10:01:12 +02:00
committed by GitHub
parent 21adbe2fac
commit 0b724bd4d5
23 changed files with 746 additions and 2246 deletions

View File

@@ -225,9 +225,14 @@ func (p *Peer) handleOfferedHashesMsg(ctx context.Context, req *OfferedHashesMsg
for i := 0; i < lenHashes; i += HashSize {
hash := hashes[i : i+HashSize]
if wait := c.NeedData(ctx, hash); wait != nil {
log.Trace("checking offered hash", "ref", fmt.Sprintf("%x", hash))
if _, wait := c.NeedData(ctx, hash); wait != nil {
ctr++
// set the bit, so create a request
want.Set(i/HashSize, true)
log.Trace("need data", "ref", fmt.Sprintf("%x", hash), "request", true)
// measure how long it takes before we mark chunks for retrieval, and actually send the request
if !wantDelaySet {