refactor(bitswap) perform Publish in HasBlock
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 26, 2014 at 14:22 UTC
1e7b7efa7692f4d179fd669bcef535cdb6062a1a
1 file changed
+2
-2
exchange/bitswap/bitswap.go
+2
-2
@@ -224,8 +224,10 @@ func (bs *bitswap) loop(parent context.Context) {
224
// HasBlock announces the existance of a block to this bitswap service. The
225
// service will potentially notify its peers.
226
func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
227
+ // TODO check all errors
228
log.Debugf("Has Block %s", blk.Key())
229
bs.wantlist.Remove(blk.Key())
230
+ bs.notifications.Publish(blk)
231
bs.sendToPeersThatWant(ctx, blk)
232
return bs.routing.Provide(ctx, blk.Key())
233
}
@@ -258,8 +260,6 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
260
log.Criticalf("error putting block: %s", err)
261
continue // FIXME(brian): err ignored
262
}
261
- bs.notifications.Publish(block)
262
- bs.wantlist.Remove(block.Key())
263
err := bs.HasBlock(ctx, block)
264
if err != nil {
265
log.Warningf("HasBlock errored: %s", err)