Documentation ¶
Overview ¶
package routing defines the interface for a routing system used by ipfs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("routing: not found")
ErrNotFound is returned when a search fails to find anything
var ErrNotSupported = errors.New("routing: operation or key not supported")
ErrNotSupported is returned when a search or put fails because the key type isn't supported.
Functions ¶
func GetPublicKey ¶
GetPublicKey retrieves the public key associated with the given peer ID from the value store.
If the ValueStore is also a PubKeyFetcher, this method will call GetPublicKey (which may be better optimized) instead of GetValue.
func KeyForPublicKey ¶
KeyForPublicKey returns the key used to retrieve public keys from a value store.
Types ¶
type ContentRouting ¶
type ContentRouting interface { // Provide adds the given cid to the content routing system. If 'true' is // passed, it also announces it, otherwise it is just kept in the local // accounting of which objects are being provided. Provide(context.Context, *cid.Cid, bool) error // Search for peers who are able to provide a given key FindProvidersAsync(context.Context, *cid.Cid, int) <-chan pstore.PeerInfo }
ContentRouting is a value provider layer of indirection. It is used to find information about who has what content.
type IpfsRouting ¶
type IpfsRouting interface { ContentRouting PeerRouting ValueStore // Bootstrap allows callers to hint to the routing system to get into a // Boostrapped state Bootstrap(context.Context) error }
IpfsRouting is the combination of different routing types that ipfs uses. It can be satisfied by a single item (such as a DHT) or multiple different pieces that are more optimized to each task.
type PeerRouting ¶
type PeerRouting interface { // Find specific Peer // FindPeer searches for a peer with given ID, returns a pstore.PeerInfo // with relevant addresses. FindPeer(context.Context, peer.ID) (pstore.PeerInfo, error) }
PeerRouting is a way to find information about certain peers. This can be implemented by a simple lookup table, a tracking server, or even a DHT.
type PubKeyFetcher ¶
type PubKeyFetcher interface { // GetPublicKey returns the public key for the given peer. GetPublicKey(context.Context, peer.ID) (ci.PubKey, error) }
PubKeyFetcher is an interfaces that should be implemented by value stores that can optimize retrieval of public keys.
TODO(steb): Consider removing, see #22.
type ValueStore ¶
type ValueStore interface { // PutValue adds value corresponding to given Key. PutValue(context.Context, string, []byte, ...ropts.Option) error // GetValue searches for the value corresponding to given Key. GetValue(context.Context, string, ...ropts.Option) ([]byte, error) }
ValueStore is a basic Put/Get interface.