Documentation
¶
Overview ¶
package dht implements a distributed hash table that satisfies the ipfs routing interface. This DHT is modeled after kademlia with Coral and S/Kademlia modifications.
Index ¶
- Variables
- type IpfsDHT
- func (dht *IpfsDHT) Bootstrap(ctx context.Context)
- func (dht *IpfsDHT) Connect(ctx context.Context, npeer peer.Peer) (peer.Peer, error)
- func (dht *IpfsDHT) FindLocal(id peer.ID) (peer.Peer, *kb.RoutingTable)
- func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (peer.Peer, error)
- func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int) <-chan peer.Peer
- func (dht *IpfsDHT) GetValue(ctx context.Context, key u.Key) ([]byte, error)
- func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.NetMessage
- func (dht *IpfsDHT) Ping(ctx context.Context, p peer.Peer) error
- func (dht *IpfsDHT) PingRoutine(t time.Duration)
- func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error
- func (dht *IpfsDHT) PutValue(ctx context.Context, key u.Key, value []byte) error
- func (dht *IpfsDHT) Update(p peer.Peer)
- type ProviderManager
Constants ¶
This section is empty.
Variables ¶
var AlphaValue = 3
Alpha is the concurrency factor for asynchronous requests.
var CloserPeerCount = 4
The number of closer peers to send on requests.
var KValue = 10
K is the maximum number of requests to perform before returning failure.
var PoolSize = 6
Pool size is the number of nodes used for group find/set RPC calls
Functions ¶
This section is empty.
Types ¶
type IpfsDHT ¶
type IpfsDHT struct { ctxc.ContextCloser // contains filtered or unexported fields }
IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications. It is used to implement the base IpfsRouting module.
func NewDHT ¶
func NewDHT(ctx context.Context, p peer.Peer, ps peer.Peerstore, dialer inet.Dialer, sender inet.Sender, dstore ds.Datastore) *IpfsDHT
NewDHT creates a new DHT object with the given peer as the 'local' host
func (*IpfsDHT) Connect ¶
Connect to a new peer at the given address, ping and add to the routing table
func (*IpfsDHT) FindLocal ¶
FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
func (*IpfsDHT) FindProvidersAsync ¶
func (*IpfsDHT) GetValue ¶
GetValue searches for the value corresponding to given Key. If the search does not succeed, a multiaddr string of a closer peer is returned along with util.ErrSearchIncomplete
func (*IpfsDHT) HandleMessage ¶
func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.NetMessage
HandleMessage implements the inet.Handler interface.
func (*IpfsDHT) PingRoutine ¶
PingRoutine periodically pings nearest neighbors.
func (*IpfsDHT) Provide ¶
Provide makes this node announce that it can provide a value for the given key
type ProviderManager ¶
type ProviderManager struct { ctxc.ContextCloser // contains filtered or unexported fields }
func NewProviderManager ¶
func NewProviderManager(ctx context.Context, local peer.ID) *ProviderManager
func (*ProviderManager) AddProvider ¶
func (pm *ProviderManager) AddProvider(k u.Key, val peer.Peer)
func (*ProviderManager) GetLocal ¶
func (pm *ProviderManager) GetLocal() []u.Key
func (*ProviderManager) GetProviders ¶
func (pm *ProviderManager) GetProviders(k u.Key) []peer.Peer