master
go 29 lines 1008 Bytes
Raw
1 package iface
2
3 import (
4 "context"
5
6 "github.com/ipfs/boxo/path"
7 "github.com/ipfs/kubo/core/coreiface/options"
8 "github.com/libp2p/go-libp2p/core/peer"
9 )
10
11 // RoutingAPI specifies the interface to the routing layer.
12 type RoutingAPI interface {
13 // Get retrieves the best value for a given key
14 Get(context.Context, string) ([]byte, error)
15
16 // Put sets a value for a given key
17 Put(ctx context.Context, key string, value []byte, opts ...options.RoutingPutOption) error
18
19 // FindPeer queries the routing system for all the multiaddresses associated
20 // with the given [peer.ID].
21 FindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
22
23 // FindProviders finds the peers in the routing system who can provide a specific
24 // value given a key.
25 FindProviders(context.Context, path.Path, ...options.RoutingFindProvidersOption) (<-chan peer.AddrInfo, error)
26
27 // Provide announces to the network that you are providing given values
28 Provide(context.Context, path.Path, ...options.RoutingProvideOption) error
29 }