routing.go 974 Bytes
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2
package routing

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
3
import (
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
4 5 6
	peer "github.com/jbenet/go-ipfs/peer"
	u "github.com/jbenet/go-ipfs/util"
	"time"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
7
)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
8

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
9 10 11 12
// IpfsRouting is the routing module interface
// It is implemented by things like DHTs, etc.
type IpfsRouting interface {

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
13
	// Basic Put/Get
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
14

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
15 16
	// PutValue adds value corresponding to given Key.
	PutValue(key u.Key, value []byte) error
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
17

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
18 19
	// GetValue searches for the value corresponding to given Key.
	GetValue(key u.Key, timeout time.Duration) ([]byte, error)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
20

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
21 22
	// Value provider layer of indirection.
	// This is what DSHTs (Coral and MainlineDHT) do to store large values in a DHT.
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
23

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
24 25
	// Announce that this node can provide value for given key
	Provide(key u.Key) error
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
26

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
27
	// FindProviders searches for peers who can provide the value for given key.
28
	FindProviders(key u.Key, timeout time.Duration) ([]*peer.Peer, error)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
29

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
30
	// Find specific Peer
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
31

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
32 33
	// FindPeer searches for a peer with given ID.
	FindPeer(id peer.ID, timeout time.Duration) (*peer.Peer, error)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
34
}