ipfs / ipfs/boxo

[ipfs/go-bitswap] Bitswap client usage unintuitive

Open
#68 2 comments 0 reactions 0 assignees View on GitHub
need/triage
Dominant language
Go
Stars
316
Forks
163
Avg merge
4d 12h
Merged PRs (30d)
8

Description

Since ipfs/go-bitswap#570 has made it possible to use the client and server pieces of go-bitswap independently it would seem reasonable that someone could replace:

```
bsnet := bsnet.NewFromIpfsHost(h, &rhelp.Null{})
bswap := bitswap.New(ctx, bsnet, bstore)
block, err := bswap.GetBlock(ctx, someCID)
```

with

```
bsnet := bsnet.NewFromIpfsHost(h, &rhelp.Null{})
bswap := bsclient.New(ctx, bsnet, bstore)
block, err := bswap.GetBlock(ctx, someCID)
```

especially since there are no compile-time errors or comments on the client that would indicate otherwise. However, unless `bsnet.Start(bswap)` is called on the client (not required when using `bitswap.New`) the code will silently hang as the response messages are not being processed.

IMO this footgun should be removed so that `bsclient.New` can drop-in for `bitswap.New` when no server functionality is required. An easy, if inelegant, option might be to call `bsnet.Start(bswap)` unless an option is passed in telling it not to and then passing that option internally in the `bitswap.New` constructor that creates the client. If not resolved at least there should be some comments on the client (and I suspect server) constructor letting people know they need to register their client/server with the BitswapNetwork in order to function.

wdyt @Jorropo @guseggert ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.