提交 8c05c444 作者: Brian Tiger Chow 提交者: Juan Batiz-Benet

refactor: avoid loop reuse

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 2ea8ed81
......@@ -309,14 +309,16 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
// TODO: this is bad, and could be easily abused.
// Should only track *useful* messages in ledger
var blkeys []u.Key
for _, block := range incoming.Blocks() {
blkeys = append(blkeys, block.Key())
hasBlockCtx, _ := context.WithTimeout(ctx, hasBlockTimeout)
if err := bs.HasBlock(hasBlockCtx, block); err != nil {
log.Error(err)
}
}
var blkeys []u.Key
for _, block := range incoming.Blocks() {
blkeys = append(blkeys, block.Key())
}
if len(blkeys) > 0 {
bs.cancelBlocks(ctx, blkeys)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论