kademlia

package
v0.0.0-...-39387bb Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PING                = 0
	PING_RESPONSE       = 1
	FIND_NODE           = 2
	FIND_NODE_RESPONSE  = 3
	FIND_VALUE          = 4
	FIND_VALUE_RESPONSE = 5
	STORE               = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidates

type Candidates struct {
	// contains filtered or unexported fields
}

func (*Candidates) CalcDistances

func (candidates *Candidates) CalcDistances(target *kademliaid.T)

type RPCFindNode

type RPCFindNode struct {
	RPCType int
	Sender  contact.T
	FindID  kademliaid.T
}

type RPCFindNodeResponse

type RPCFindNodeResponse struct {
	RPCType  int
	Sender   contact.T
	Contacts []contact.T
}

type RPCFindValue

type RPCFindValue struct {
	RPCType int
	Sender  contact.T
	FindID  kademliaid.T
}

type RPCFindValueResponse

type RPCFindValueResponse struct {
	RPCType  int
	Sender   contact.T
	Value    kvstore.Value
	Contacts []contact.T
}

type RPCHeader

type RPCHeader struct {
	RPCType int
	Sender  contact.T
}

type RPCPing

type RPCPing struct {
	RPCType int
	Sender  contact.T
}

type RPCPingResponse

type RPCPingResponse struct {
	RPCType int
	Sender  contact.T
}

type RPCStore

type RPCStore struct {
	RPCType int
	Sender  contact.T
	Value   kvstore.Value
}

type T

type T struct {
	// contains filtered or unexported fields
}

func New

func New(contactMe *contact.T) *T

func (*T) Cat

func (t *T) Cat(id kademliaid.T) []byte

func (*T) FindNode

func (nw *T) FindNode(c *contact.T, findID *kademliaid.T) ([]contact.T, error)

func (*T) FindValue

func (nw *T) FindValue(c *contact.T, findID *kademliaid.T) (kvstore.Value, []contact.T, bool, error)

FindValue returns the value if it was found or some []contacts if it wasn't. The third return value is a bool that is true if the value was found.

func (*T) Join

func (t *T) Join(address string) error

A kademlia node t can join the network as long as they know the address of a node already on the network This method connects t to the rest of the network

func (*T) KademliaStore

func (t *T) KademliaStore(data []byte) kademliaid.T

func (*T) Listen

func (nw *T) Listen(address string)

func (*T) LookupContact

func (t *T) LookupContact(target *kademliaid.T) []contact.T

func (*T) LookupData

func (t *T) LookupData(target *kademliaid.T) (kvstore.Value, error)

func (*T) Pin

func (t *T) Pin(id kademliaid.T)

Updates the timestamp and sets the Pin field to true

func (*T) Ping

func (nw *T) Ping(c *contact.T) error

func (*T) Store

func (nw *T) Store(c *contact.T, val *kvstore.Value) error

func (*T) Unpin

func (t *T) Unpin(id kademliaid.T)

Similar to Pin with the exception that the Pin field is set to false

Jump to

Keyboard shortcuts

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