kademlia

package module
v0.0.0-...-2e390db Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 10 Imported by: 0

README

Kademlia

This is a golang implementation of a Kademlia for the purpose of studying. It is not recommended to use for production environment.

Installation

cli
$ go run cmd/kadcli.go LISTEN_IP LISTEN_PORT BOOTSTRAP_IP BOOTSTRAP_PORT

License

MIT

Documentation

Index

Constants

View Source
const BucketSize = 20
View Source
const KadIdLen = 160 // bits
View Source
const KadIdLenByte = KadIdLen / 8 // bytes

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

func GetHostIp

func GetHostIp() (net.IP, error)

func SetLogLevelDebug

func SetLogLevelDebug()

func SetLogLevelInfo

func SetLogLevelInfo()

Types

type KadID

type KadID [KadIdLenByte]byte

func GenerateRandomKadId

func GenerateRandomKadId() KadID

type Kademlia

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

func NewKademlia

func NewKademlia(own *Node) *Kademlia

func (*Kademlia) Bootstrap

func (kad *Kademlia) Bootstrap(entryNodeAddr string, entryNodePort int) error

func (*Kademlia) FindValue

func (kad *Kademlia) FindValue(key string)

func (*Kademlia) GetRoutingTable

func (kad *Kademlia) GetRoutingTable() [KadIdLen]list.List

For debug purpose

func (*Kademlia) Leave

func (kad *Kademlia) Leave()

func (*Kademlia) SendFindNodeQuery

func (kad *Kademlia) SendFindNodeQuery(ip net.IP, port int, target KadID) error

func (*Kademlia) SetFindValueCallback

func (kad *Kademlia) SetFindValueCallback(fn func(string, []byte))

func (*Kademlia) Store

func (kad *Kademlia) Store(key string, value []byte)

type Node

type Node struct {
	Id   KadID
	IP   net.IP
	Port int
}

func NewNode

func NewNode(id KadID, ip net.IP, port int) *Node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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