-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,20 +253,10 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error { | |
bs.wantlist.Remove(blk.Key()) | ||
bs.notifications.Publish(blk) | ||
|
||
var err error | ||
wg := &sync.WaitGroup{} | ||
wg.Add(2) | ||
child, _ := context.WithTimeout(ctx, hasBlockTimeout) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
whyrusleeping
Author
Member
|
||
go func() { | ||
bs.sendToPeersThatWant(child, blk) | ||
wg.Done() | ||
}() | ||
go func() { | ||
err = bs.routing.Provide(child, blk.Key()) | ||
wg.Done() | ||
}() | ||
wg.Wait() | ||
return err | ||
bs.sendToPeersThatWant(child, blk) | ||
child, _ = context.WithTimeout(ctx, hasBlockTimeout) | ||
return bs.routing.Provide(child, blk.Key()) | ||
} | ||
|
||
// receiveBlock handles storing the block in the blockstore and calling HasBlock | ||
|
the context can be shared between the two functions. no need to create one for each