routing.go 975 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 (
4 5
	"time"

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
6 7
	peer "github.com/jbenet/go-ipfs/peer"
	u "github.com/jbenet/go-ipfs/util"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
8
)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
9

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
10 11 12 13
// 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
14
	// Basic Put/Get
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
15

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

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
19 20
	// 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
21

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
22 23
	// 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
24

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

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

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

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
33 34
	// 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
35
}