kademlia

package module
v0.0.0-...-d19ab34 Latest Latest
Warning

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

Go to latest
Published: May 13, 2018 License: Unlicense Imports: 18 Imported by: 2

README

Kademlia

Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia Kademlia

Running Kademlia

If you use the script in the slurm_stuff folder called run_slurm.sh and give it the IP address of the node the script is being run on, it'll start the bootstrap node on the current node and then ask Slurm to run 4 nodes that'll ping the bootstrap node 4 times.

***Note that Go isn't installed on all the nodes, so you need to run go build and run the binary instead

Documentation

Index

Constants

View Source
const Bootstrap_node_path = "/home/pdelong/go/src/github.com/peterdelong/kademlia/cmd/kademlia_node/bootstrap_nodes"

Variables

This section is empty.

Functions

func AreEqualContacts

func AreEqualContacts(a *Contact, b *Contact) bool

AreEqualContacts returns true if contact Id and Addr are equivalent structs can be compared, but structs containing big.Int cannot

Types

type Contact

type Contact struct {
	Id   big.Int
	Addr net.TCPAddr
}

Contact is an entry in the k-bucket

func NewContact

func NewContact(addr net.TCPAddr) *Contact

NewContact creates a new Contact struct based on addr by taking the hash

func RemoveDupesFromShortlist

func RemoveDupesFromShortlist(contacts []Contact) []Contact

type FindNodeArgs

type FindNodeArgs struct {
	Source net.TCPAddr
	Key    string
}

FindNodeArgs contains the arguments for the FINDNODE RPC

type FindNodeReply

type FindNodeReply struct {
	Contacts []Contact
}

FindNodeReply contains the results for the FINDNODE RPC

type FindValueArgs

type FindValueArgs struct {
	Source net.TCPAddr
	Key    string
}

FindValueArgs contains the arguments for the FINDVALUE RPC

type FindValueReply

type FindValueReply struct {
	Val      []byte
	Contacts []Contact
}

FindValueReply contains the results for the FINDVALUE RPC

type KBucket

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

func NewKBucket

func NewKBucket(k int) *KBucket

type KV

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

KV contains all the information we have for a key

type KVStore

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

KVStore holds mappings from keys to values and keeps track if a given node is the owner of the value

func NewKVStore

func NewKVStore() *KVStore

NewKVStore returns a newly initialized KVStore

func (*KVStore) Iterator

func (store *KVStore) Iterator() chan *KV

Iterator returns a channel that iterates over all the keys that we've stored

type Node

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

Node is an individual Kademlia node

func NewNode

func NewNode(address string) *Node

NewNode returns a new Node struct

func (*Node) FindNode

func (node *Node) FindNode(args FindNodeArgs, reply *FindNodeReply) error

FindNode is the handler for the FINDNODE RPC

func (*Node) FindValue

func (node *Node) FindValue(args FindValueArgs, reply *FindValueReply) error

FindValue is the handler for the FINDVALUE RPC

func (*Node) GetKBucketFromAddr

func (node *Node) GetKBucketFromAddr(destAddr net.TCPAddr) int

GetKBucketFromAddr returns the KBucket that would contain destAddr

func (*Node) GetKBucketFromID

func (node *Node) GetKBucketFromID(destID *big.Int) int

GetKBucketFromID returns the KBucket that would contain destID

func (*Node) Ping

func (node *Node) Ping(args PingArgs, reply *PingReply) error

Ping is the handler for the PING RPC

func (*Node) Run

func (node *Node) Run(toPing string)

Run is called on an initialized Node to begin serving the RPC endpoints

func (*Node) Store

func (node *Node) Store(args StoreArgs, reply *StoreReply) error

Store is the handler for the STORE RPC

func (*Node) String

func (node *Node) String() string

type NodeRPC

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

NodeRPC is a wrapper struct that is used to control which RPCs are exposed

func (*NodeRPC) FindNode

func (fakeNode *NodeRPC) FindNode(args FindNodeArgs, reply *FindNodeReply) error

FindNode is a stub function that exposes the FINDNODE RPC

func (*NodeRPC) FindValue

func (fakeNode *NodeRPC) FindValue(args FindValueArgs, reply *FindValueReply) error

FindValue is a stub function that exposes the FINDVALUE RPC

func (*NodeRPC) Ping

func (fakeNode *NodeRPC) Ping(args PingArgs, reply *PingReply) error

Ping is a stub function that exposes the PING RPC

func (*NodeRPC) Store

func (fakeNode *NodeRPC) Store(args StoreArgs, reply *StoreReply) error

Store is a stub function that exposes the STORE RPC

type PingArgs

type PingArgs struct {
	Source net.TCPAddr
}

PingArgs contains the arguments for the PING RPC

type PingReply

type PingReply struct {
	Source net.TCPAddr
}

PingReply contains the results for the PING RPC

type RoutingTable

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

extra struct because we will want to implement split bucket

func NewRoutingTable

func NewRoutingTable(owner *Node) *RoutingTable

func (*RoutingTable) ContactFromID

func (table *RoutingTable) ContactFromID(id big.Int) *Contact

ContactFromID returns the contact that belongs to id if it exists and nil if it doesn't

type StoreArgs

type StoreArgs struct {
	Source net.TCPAddr
	Key    string
	Val    []byte
}

StoreArgs contains the arguments for the STORE RPC

type StoreReply

type StoreReply struct {
}

StoreReply contains the results for the Store RPC

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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