dht.go 889 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

Raúl Kripalani's avatar
Raúl Kripalani committed
9
	"github.com/libp2p/go-libp2p-core/peer"
Ł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
Raúl Kripalani's avatar
Raúl Kripalani committed
18
	FindPeer(context.Context, peer.ID) (peer.AddrInfo, 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.
Raúl Kripalani's avatar
Raúl Kripalani committed
22
	FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan peer.AddrInfo, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
23

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