dht.go 1.18 KB
Newer Older
Łukasz Magiera's avatar
Łukasz Magiera committed
1 2 3 4 5 6 7
package iface

import (
	"context"

	options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"

8 9
	peer "gx/ipfs/QmQsErDt8Qgw1XrsXf2BpEzDgGWtB1YLsTAARBup5b6B9W/go-libp2p-peer"
	ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
Łukasz Magiera's avatar
Łukasz Magiera committed
10 11 12 13 14 15 16 17 18 19
)

// DhtAPI specifies the interface to the DHT
type DhtAPI interface {
	// FindPeer queries the DHT for all of the multiaddresses associated with a
	// Peer ID
	FindPeer(context.Context, peer.ID) (<-chan ma.Multiaddr, error)

	// FindProviders finds peers in the DHT who can provide a specific value
	// given a key.
Łukasz Magiera's avatar
Łukasz Magiera committed
20 21 22 23 24
	FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan peer.ID, error) //TODO: is path the right choice here?

	// WithNumProviders is an option for FindProviders which specifies the
	// number of peers to look for. Default is 20
	WithNumProviders(numProviders int) options.DhtFindProvidersOption
Łukasz Magiera's avatar
Łukasz Magiera committed
25 26 27 28 29 30 31 32

	// Provide announces to the network that you are providing given values
	Provide(context.Context, Path, ...options.DhtProvideOption) error

	// WithRecursive is an option for Provide which specifies whether to provide
	// the given path recursively
	WithRecursive(recursive bool) options.DhtProvideOption
}