Skip to content

[ipfs/go-bitswap] Bitswap client usage unintuitive #68

@aschmahmann

Description

@aschmahmann

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions