@cryptotaxi247 / kubo / commits / 8bef1dce8

fix: move to callsite so public callers don't experience the internal timeout rule

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 16, 2014 at 20:09 UTC 8bef1dce804db407a48031de8ba6bec114769105
1 file changed +3 -3
exchange/bitswap/bitswap.go
+3 -3
@@ -159,8 +159,7 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
159 }
160 bs.wantlist.Remove(blk.Key())
161 bs.notifications.Publish(blk)
162 - child, _ := context.WithTimeout(ctx, hasBlockTimeout)
163 - return bs.routing.Provide(child, blk.Key())
162 + return bs.routing.Provide(ctx, blk.Key())
163 }
164
165 func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) error {
@@ -319,7 +318,8 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
318 var blkeys []u.Key
319 for _, block := range incoming.Blocks() {
320 blkeys = append(blkeys, block.Key())
322 - if err := bs.HasBlock(ctx, block); err != nil {
321 + hasBlockCtx, _ := context.WithTimeout(ctx, hasBlockTimeout)
322 + if err := bs.HasBlock(hasBlockCtx, block); err != nil {
323 log.Error(err)
324 }
325 }