1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-03 13:00:37 +08:00

refac(bitswap) nil slices are 'range'able

This commit is contained in:
Brian Tiger Chow
2014-09-19 15:44:11 -07:00
parent 331fcd1756
commit 5aa6ccbad5

View File

@ -117,32 +117,28 @@ func (bs *bitswap) ReceiveMessage(
bs.strategy.MessageReceived(p, incoming) bs.strategy.MessageReceived(p, incoming)
if incoming.Blocks() != nil { for _, block := range incoming.Blocks() {
for _, block := range incoming.Blocks() { err := bs.blockstore.Put(block) // FIXME(brian): err ignored
err := bs.blockstore.Put(block) // FIXME(brian): err ignored if err != nil {
if err != nil { return nil, nil, err
return nil, nil, err }
} bs.notifications.Publish(block)
bs.notifications.Publish(block) err = bs.HasBlock(ctx, block) // FIXME err ignored
err = bs.HasBlock(ctx, block) // FIXME err ignored if err != nil {
if err != nil { return nil, nil, err
return nil, nil, err
}
} }
} }
if incoming.Wantlist() != nil { for _, key := range incoming.Wantlist() {
for _, key := range incoming.Wantlist() { if bs.strategy.ShouldSendBlockToPeer(key, p) {
if bs.strategy.ShouldSendBlockToPeer(key, p) { block, errBlockNotFound := bs.blockstore.Get(key)
block, errBlockNotFound := bs.blockstore.Get(key) if errBlockNotFound != nil {
if errBlockNotFound != nil { return nil, nil, errBlockNotFound
return nil, nil, errBlockNotFound
}
message := bsmsg.New()
message.AppendBlock(*block)
defer bs.strategy.MessageSent(p, message)
return p, message, nil
} }
message := bsmsg.New()
message.AppendBlock(*block)
defer bs.strategy.MessageSent(p, message)
return p, message, nil
} }
} }
return nil, nil, nil return nil, nil, nil