1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 09:59:13 +08:00

docs(bitswap:notifications) Subscribe

This commit is contained in:
Brian Tiger Chow
2014-09-12 02:46:38 -07:00
parent b1155a0bb6
commit cc163a955d

View File

@ -22,8 +22,9 @@ func (ps *notifications) Publish(block *blocks.Block) {
ps.wrapped.Pub(block, topic)
}
// Sub returns a one-time use |blockChannel|. |blockChannel| returns nil if the
// |ctx| times out or is cancelled
// Subscribe returns a one-time use |blockChannel|. |blockChannel| returns nil
// if the |ctx| times out or is cancelled. Then channel is closed after the
// block given by |k| is sent.
func (ps *notifications) Subscribe(ctx context.Context, k u.Key) <-chan *blocks.Block {
topic := string(k)
subChan := ps.wrapped.SubOnce(topic)