Documentation ¶
Index ¶
- Constants
- func SendMsg(conn *net.UDPConn, returnAddress *net.UDPAddr, msg Message)
- type Kademlia
- func (dht *Kademlia) FindNode(remote *RemoteNode, cmp NodeID) string
- func (dht *Kademlia) FindValue(remote *RemoteNode, key string) string
- func (dht *Kademlia) LocalStore(key string, value interface{})
- func (dht *Kademlia) Ping(remote *RemoteNode) string
- func (dht *Kademlia) PingIP(addr *net.UDPAddr) string
- func (dht *Kademlia) Run()
- func (dht *Kademlia) Store(remote *RemoteNode, key string, value interface{}) string
- type Message
- type Node
- func (node Node) Delete(remote *RemoteNode)
- func (node Node) GetClosestNodes(n int) []*RemoteNode
- func (node Node) GetNClosestNodes(target NodeID, n int) []*RemoteNode
- func (node Node) GetNearestNode() *RemoteNode
- func (node Node) GetNode(id NodeID) (remote *RemoteNode)
- func (node Node) GetNodeFromAddress(address string) (remote *RemoteNode, exists bool)
- func (node Node) GetOrCreateNode(id NodeID, address string) (remote *RemoteNode)
- func (node Node) SpringClean()
- func (node Node) Update(cmp *RemoteNode)
- type NodeID
- type RemoteNode
- type ResponseFunc
Constants ¶
View Source
const ( ID_SIZE int = 20 BUCKET_SIZE int = 20 K = 8 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Kademlia ¶
type Kademlia struct { Node *Node Name string // this is used as the chatroom ID Connection *net.UDPConn ResponseHandler map[string]ResponseFunc AwaitingResponse map[string]time.Time // key is token - req/rep method ExtraInfo map[string]interface{} // key is token. This is a store of random things that may be needed ResultChan map[string]chan interface{} // key is token // contains filtered or unexported fields }
func NewKademlia ¶
func NewKademlia() *Kademlia
func (*Kademlia) LocalStore ¶
LocalStore basically stores data in the local node
func (*Kademlia) Ping ¶
func (dht *Kademlia) Ping(remote *RemoteNode) string
type Message ¶
this is exported to allow for new query types although now only the 4 basic kademlia queries will be allowed
func NewMessage ¶
func (*Message) InsertMessage ¶
func (msg *Message) InsertMessage(message interface{})
type Node ¶
type Node struct { ID NodeID IP string Port int RoutingTable *routingTable AddressToNode map[string]*RemoteNode Store map[string]interface{} }
func (Node) GetClosestNodes ¶
func (node Node) GetClosestNodes(n int) []*RemoteNode
func (Node) GetNClosestNodes ¶
func (node Node) GetNClosestNodes(target NodeID, n int) []*RemoteNode
func (Node) GetNearestNode ¶
func (node Node) GetNearestNode() *RemoteNode
func (Node) GetNode ¶
func (node Node) GetNode(id NodeID) (remote *RemoteNode)
func (Node) GetNodeFromAddress ¶
func (node Node) GetNodeFromAddress(address string) (remote *RemoteNode, exists bool)
R
func (Node) GetOrCreateNode ¶
func (node Node) GetOrCreateNode(id NodeID, address string) (remote *RemoteNode)
func (Node) SpringClean ¶
func (node Node) SpringClean()
spring clean basically purges the AddressToNode map, and refills it. spring cleaning should ideally happen every 10 minutes or so
type RemoteNode ¶
type ResponseFunc ¶
type ResponseFunc func(*RemoteNode, string, NodeID, interface{})
Click to show internal directories.
Click to hide internal directories.