dht.go 953 Bytes
Newer Older
Łukasz Magiera's avatar
Łukasz Magiera committed
1 2 3 4 5
package iface

import (
	"context"

Łukasz Magiera's avatar
Łukasz Magiera committed
6
	"github.com/ipfs/interface-go-ipfs-core/options"
Łukasz Magiera's avatar
Łukasz Magiera committed
7

Steven Allen's avatar
Steven Allen committed
8 9
	peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp2p-peer"
	pstore "gx/ipfs/QmQFFp4ntkd4C14sP3FaH9WJyBuetuGUVo6dShNHvnoEvC/go-libp2p-peerstore"
Łukasz Magiera's avatar
Łukasz Magiera committed
10 11 12
)

// DhtAPI specifies the interface to the DHT
13
// Note: This API will likely get deprecated in near future, see
14
// https://github.com/ipfs/interface-ipfs-core/issues/249 for more context.
Łukasz Magiera's avatar
Łukasz Magiera committed
15 16 17
type DhtAPI interface {
	// FindPeer queries the DHT for all of the multiaddresses associated with a
	// Peer ID
18
	FindPeer(context.Context, peer.ID) (pstore.PeerInfo, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
19 20 21

	// FindProviders finds peers in the DHT who can provide a specific value
	// given a key.
22
	FindProviders(context.Context, Path, ...options.DhtFindProvidersOption) (<-chan pstore.PeerInfo, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
23

Łukasz Magiera's avatar
Łukasz Magiera committed
24 25 26
	// Provide announces to the network that you are providing given values
	Provide(context.Context, Path, ...options.DhtProvideOption) error
}