dht

package
v0.0.0-...-bebc87d Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var AlphaValue = 3

Its in the paper, i swear

View Source
var KValue = 10

We put the 'K' in kademlia!

View Source
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",
}
View Source
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,
}
View Source
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) Bootstrap

func (dht *IpfsDHT) Bootstrap(ctx context.Context)

Bootstrap builds up list of peers by requesting random peer IDs

func (*IpfsDHT) Connect

func (dht *IpfsDHT) Connect(ctx context.Context, npeer *peer.Peer) (*peer.Peer, error)

Connect to a new peer at the given address, ping and add to the routing table

func (*IpfsDHT) Find

func (dht *IpfsDHT) Find(id peer.ID) (*peer.Peer, *kb.RoutingTable)

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) FindPeer

func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (*peer.Peer, error)

FindPeer searches for a peer with given ID.

func (*IpfsDHT) FindProviders

func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]*peer.Peer, error)

FindProviders searches for peers who can provide the value for given key.

func (*IpfsDHT) FindProvidersAsync

func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key u.Key, count int) <-chan *peer.Peer

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

func (dht *IpfsDHT) GetValue(ctx context.Context, key u.Key) ([]byte, error)

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) Ping

func (dht *IpfsDHT) Ping(ctx context.Context, p *peer.Peer) error

Ping a peer, log the time it took

func (*IpfsDHT) Provide

func (dht *IpfsDHT) Provide(ctx context.Context, key u.Key) error

Provide makes this node announce that it can provide a value for the given key

func (*IpfsDHT) PutValue

func (dht *IpfsDHT) PutValue(ctx context.Context, key u.Key, value []byte) error

PutValue adds value corresponding to given Key. This is the top level "Store" operation of the DHT

func (*IpfsDHT) Update

func (dht *IpfsDHT) Update(p *peer.Peer)

Update signals to all routingTables to Update their last-seen status on the given peer.

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

func (m *Message) GetClusterLevel() int

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 (m *Message) GetClusterLevelRaw() int32

func (*Message) GetKey

func (m *Message) GetKey() string

func (*Message) GetProviderPeers

func (m *Message) GetProviderPeers() []*Message_Peer

func (*Message) GetType

func (m *Message) GetType() Message_MessageType

func (*Message) GetValue

func (m *Message) GetValue() []byte

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) SetClusterLevel

func (m *Message) SetClusterLevel(level int)

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)

func (*Message) String

func (m *Message) String() string

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 (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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳