mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 02:30:39 +08:00
docs(bitswap:notifications) Subscribe
This commit is contained in:
@ -22,8 +22,9 @@ func (ps *notifications) Publish(block *blocks.Block) {
|
|||||||
ps.wrapped.Pub(block, topic)
|
ps.wrapped.Pub(block, topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sub returns a one-time use |blockChannel|. |blockChannel| returns nil if the
|
// Subscribe returns a one-time use |blockChannel|. |blockChannel| returns nil
|
||||||
// |ctx| times out or is cancelled
|
// 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 {
|
func (ps *notifications) Subscribe(ctx context.Context, k u.Key) <-chan *blocks.Block {
|
||||||
topic := string(k)
|
topic := string(k)
|
||||||
subChan := ps.wrapped.SubOnce(topic)
|
subChan := ps.wrapped.SubOnce(topic)
|
||||||
|
Reference in New Issue
Block a user