提交 1e7b7efa 作者: Brian Tiger Chow 提交者: Jeromy

refactor(bitswap) perform Publish in HasBlock

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 829eac30
...@@ -224,8 +224,10 @@ func (bs *bitswap) loop(parent context.Context) { ...@@ -224,8 +224,10 @@ func (bs *bitswap) loop(parent context.Context) {
// HasBlock announces the existance of a block to this bitswap service. The // HasBlock announces the existance of a block to this bitswap service. The
// service will potentially notify its peers. // service will potentially notify its peers.
func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error { func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
// TODO check all errors
log.Debugf("Has Block %s", blk.Key()) log.Debugf("Has Block %s", blk.Key())
bs.wantlist.Remove(blk.Key()) bs.wantlist.Remove(blk.Key())
bs.notifications.Publish(blk)
bs.sendToPeersThatWant(ctx, blk) bs.sendToPeersThatWant(ctx, blk)
return bs.routing.Provide(ctx, blk.Key()) return bs.routing.Provide(ctx, blk.Key())
} }
...@@ -258,8 +260,6 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm ...@@ -258,8 +260,6 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
log.Criticalf("error putting block: %s", err) log.Criticalf("error putting block: %s", err)
continue // FIXME(brian): err ignored continue // FIXME(brian): err ignored
} }
bs.notifications.Publish(block)
bs.wantlist.Remove(block.Key())
err := bs.HasBlock(ctx, block) err := bs.HasBlock(ctx, block)
if err != nil { if err != nil {
log.Warningf("HasBlock errored: %s", err) log.Warningf("HasBlock errored: %s", err)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论