Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require the protocol id when creating a new DHT or DHT client. #704

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func New(ctx context.Context, h host.Host, options ...Option) (*IpfsDHT, error)
// NewDHT creates a new DHT object with the given peer as the 'local' host.
// IpfsDHT's initialized with this function will respond to DHT requests,
// whereas IpfsDHT's initialized with NewDHTClient will not.
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
dht, err := New(ctx, h, Datastore(dstore))
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching, protocolPrefix protocol.ID) *IpfsDHT {
dht, err := New(ctx, h, Datastore(dstore), ProtocolPrefix(protocolPrefix))
if err != nil {
panic(err)
}
Expand All @@ -257,8 +257,8 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
// NewDHTClient creates a new DHT object with the given peer as the 'local'
// host. IpfsDHT clients initialized with this function will not respond to DHT
// requests. If you need a peer to respond to DHT requests, use NewDHT instead.
func NewDHTClient(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
dht, err := New(ctx, h, Datastore(dstore), Mode(ModeClient))
func NewDHTClient(ctx context.Context, h host.Host, dstore ds.Batching, protocolPrefix protocol.ID) *IpfsDHT {
dht, err := New(ctx, h, Datastore(dstore), Mode(ModeClient), ProtocolPrefix(protocolPrefix))
if err != nil {
panic(err)
}
Expand Down