Documentation
¶
Overview ¶
Package dht is a generated protocol buffer package.
It is generated from these files:
messages.proto
It has these top-level messages:
Message
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) Find(id peer.ID) (*peer.Peer, *kb.RoutingTable)
- func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (*peer.Peer, error)
- func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]*peer.Peer, error)
- func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int) <-chan *peer.Peer
- func (dht *IpfsDHT) FindProvidersAsync2(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) Halt()
- 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) 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 Message
- func (m *Message) GetCloserPeers() []*Message_Peer
- func (m *Message) GetClusterLevel() int
- func (m *Message) GetClusterLevelRaw() int32
- func (m *Message) GetKey() string
- func (m *Message) GetProviderPeers() []*Message_Peer
- func (m *Message) GetType() Message_MessageType
- func (m *Message) GetValue() []byte
- func (*Message) ProtoMessage()
- func (m *Message) Reset()
- func (m *Message) SetClusterLevel(level int)
- func (m *Message) String() string
- type Message_MessageType
- type Message_Peer
- type ProviderManager
Constants ¶
This section is empty.
Variables ¶
var AlphaValue = 3
Its in the paper, i swear
var KValue = 10
We put the 'K' in kademlia!
var Message_MessageType_name = map[int32]string{
0: "PUT_VALUE",
1: "GET_VALUE",
2: "ADD_PROVIDER",
3: "GET_PROVIDERS",
4: "FIND_NODE",
5: "PING",
6: "DIAGNOSTIC",
}
var Message_MessageType_value = map[string]int32{
"PUT_VALUE": 0,
"GET_VALUE": 1,
"ADD_PROVIDER": 2,
"GET_PROVIDERS": 3,
"FIND_NODE": 4,
"PING": 5,
"DIAGNOSTIC": 6,
}
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 {
// 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(p *peer.Peer, ps peer.Peerstore, net inet.Network, 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) Find ¶
Find 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) FindProviders ¶
FindProviders searches for peers who can provide the value for given key.
func (*IpfsDHT) FindProvidersAsync ¶
NB: not actually async. Used to keep the interface consistent while the actual async method, FindProvidersAsync2 is under construction
func (*IpfsDHT) FindProvidersAsync2 ¶
func (dht *IpfsDHT) FindProvidersAsync2(ctx context.Context, key u.Key, count int) <-chan *peer.Peer
FIXME: there's a bug here!
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) Halt ¶
func (dht *IpfsDHT) Halt()
Halt stops all communications from this peer and shut down TODO -- remove this in favor of context
func (*IpfsDHT) HandleMessage ¶
func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.NetMessage
HandleMessage implements the inet.Handler interface.
func (*IpfsDHT) Provide ¶
Provide makes this node announce that it can provide a value for the given key
type Message ¶
type Message struct { // defines what type of message it is. Type *Message_MessageType `protobuf:"varint,1,req,name=type,enum=dht.Message_MessageType" json:"type,omitempty"` // defines what coral cluster level this query/response belongs to. ClusterLevelRaw *int32 `protobuf:"varint,10,opt,name=clusterLevelRaw" json:"clusterLevelRaw,omitempty"` // Used to specify the key associated with this message. // PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS Key *string `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` // Used to return a value // PUT_VALUE, GET_VALUE Value []byte `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"` // Used to return peers closer to a key in a query // GET_VALUE, GET_PROVIDERS, FIND_NODE CloserPeers []*Message_Peer `protobuf:"bytes,8,rep,name=closerPeers" json:"closerPeers,omitempty"` // Used to return Providers // GET_VALUE, ADD_PROVIDER, GET_PROVIDERS ProviderPeers []*Message_Peer `protobuf:"bytes,9,rep,name=providerPeers" json:"providerPeers,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Message) GetCloserPeers ¶
func (m *Message) GetCloserPeers() []*Message_Peer
func (*Message) GetClusterLevel ¶
GetClusterLevel gets and adjusts the cluster level on the message. a +/- 1 adjustment is needed to distinguish a valid first level (1) and default "no value" protobuf behavior (0)
func (*Message) GetClusterLevelRaw ¶
func (*Message) GetProviderPeers ¶
func (m *Message) GetProviderPeers() []*Message_Peer
func (*Message) GetType ¶
func (m *Message) GetType() Message_MessageType
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) SetClusterLevel ¶
SetClusterLevel adjusts and sets the cluster level on the message. a +/- 1 adjustment is needed to distinguish a valid first level (1) and default "no value" protobuf behavior (0)
type Message_MessageType ¶
type Message_MessageType int32
const ( Message_PUT_VALUE Message_MessageType = 0 Message_GET_VALUE Message_MessageType = 1 Message_ADD_PROVIDER Message_MessageType = 2 Message_GET_PROVIDERS Message_MessageType = 3 Message_FIND_NODE Message_MessageType = 4 Message_PING Message_MessageType = 5 Message_DIAGNOSTIC Message_MessageType = 6 )
func (Message_MessageType) Enum ¶
func (x Message_MessageType) Enum() *Message_MessageType
func (Message_MessageType) String ¶
func (x Message_MessageType) String() string
func (*Message_MessageType) UnmarshalJSON ¶
func (x *Message_MessageType) UnmarshalJSON(data []byte) error
type Message_Peer ¶
type Message_Peer struct { Id *string `protobuf:"bytes,1,req,name=id" json:"id,omitempty"` Addr *string `protobuf:"bytes,2,req,name=addr" json:"addr,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Message_Peer) GetAddr ¶
func (m *Message_Peer) GetAddr() string
func (*Message_Peer) GetId ¶
func (m *Message_Peer) GetId() string
func (*Message_Peer) ProtoMessage ¶
func (*Message_Peer) ProtoMessage()
func (*Message_Peer) Reset ¶
func (m *Message_Peer) Reset()
func (*Message_Peer) String ¶
func (m *Message_Peer) String() string
type ProviderManager ¶
type ProviderManager struct {
// contains filtered or unexported fields
}
func NewProviderManager ¶
func NewProviderManager(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
func (*ProviderManager) Halt ¶
func (pm *ProviderManager) Halt()