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

import (
	"context"

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

Steven Allen's avatar
Steven Allen committed
8
	pstore "gx/ipfs/QmPiemjiKBC9VA7vZF82m4x1oygtg2c2YVqag8PX7dN1BD/go-libp2p-peerstore"
Steven Allen's avatar
Steven Allen committed
9
	peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-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
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
}