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

import (
	"context"
Łukasz Magiera's avatar
Łukasz Magiera committed
5
	path "github.com/ipfs/interface-go-ipfs-core/path"
Łukasz Magiera's avatar
Łukasz Magiera committed
6

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

Łukasz Magiera's avatar
Łukasz Magiera committed
9
	"github.com/libp2p/go-libp2p-peer"
Łukasz Magiera's avatar
Łukasz Magiera committed
10
	pstore "github.com/libp2p/go-libp2p-peerstore"
Łukasz Magiera's avatar
Łukasz Magiera committed
11 12 13
)

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

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

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