Commit 2b07d00f authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix: move the check into the function.

function should be a no-op when passed an empty slice

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 33d8110e
......@@ -315,19 +315,20 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
log.Error(err)
}
}
var blkeys []u.Key
var keys []u.Key
for _, block := range incoming.Blocks() {
blkeys = append(blkeys, block.Key())
}
if len(blkeys) > 0 {
bs.cancelBlocks(ctx, blkeys)
keys = append(keys, block.Key())
}
bs.cancelBlocks(ctx, keys)
// TODO: consider changing this function to not return anything
return nil, nil
}
func (bs *bitswap) cancelBlocks(ctx context.Context, bkeys []u.Key) {
if len(bkeys) < 1 {
return
}
message := bsmsg.New()
message.SetFull(false)
for _, k := range bkeys {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment