routing

package
v0.0.0-...-795e242 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package routing defines the interface for a routing system used by ipfs.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("routing: not found")

ErrNotFound is returned when a search fails to find anything

Functions

func GetPublicKey

func GetPublicKey(r IpfsRouting, ctx context.Context, pkhash []byte) (ci.PubKey, error)

func KeyForPublicKey

func KeyForPublicKey(id peer.ID) key.Key

KeyForPublicKey returns the key used to retrieve public keys from the dht.

Types

type IpfsRouting

type IpfsRouting interface {
	FindProvidersAsync(context.Context, key.Key, int) <-chan peer.PeerInfo

	// PutValue adds value corresponding to given Key.
	PutValue(context.Context, key.Key, []byte) error

	// GetValue searches for the value corresponding to given Key.
	GetValue(context.Context, key.Key) ([]byte, error)

	// GetValues searches for values corresponding to given Key.
	//
	// Passing a value of '0' for the count argument will cause the
	// routing interface to return values only from cached or local storage
	// and return an error if no cached value is found.
	//
	// Passing a value of '1' will return a local value if found, and query
	// the network for the first value it finds otherwise.
	// As a result, a value of '1' is mostly useful for cases where the record
	// in question has only one valid value (such as public keys)
	GetValues(c context.Context, k key.Key, count int) ([]RecvdVal, error)

	// Announce that this node can provide value for given key
	Provide(context.Context, key.Key) error

	// Find specific Peer
	// FindPeer searches for a peer with given ID, returns a peer.PeerInfo
	// with relevant addresses.
	FindPeer(context.Context, peer.ID) (peer.PeerInfo, error)

	// Bootstrap allows callers to hint to the routing system to get into a
	// Boostrapped state
	Bootstrap(context.Context) error
}

IpfsRouting is the routing module interface It is implemented by things like DHTs, etc.

type PubKeyFetcher

type PubKeyFetcher interface {
	GetPublicKey(context.Context, peer.ID) (ci.PubKey, error)
}

type RecvdVal

type RecvdVal struct {
	From peer.ID
	Val  []byte
}

RecvdVal represents a dht value record that has been received from a given peer it is used to track peers with expired records in order to correct them.

Directories

Path Synopsis
dht
Package dht implements a distributed hash table that satisfies the ipfs routing interface.
Package dht implements a distributed hash table that satisfies the ipfs routing interface.
pb
Package dht_pb is a generated protocol buffer package.
Package dht_pb is a generated protocol buffer package.
package kbucket implements a kademlia 'k-bucket' routing table.
package kbucket implements a kademlia 'k-bucket' routing table.
Package mock provides a virtual routing server.
Package mock provides a virtual routing server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL