dht

package
v0.0.0-...-8b2a550 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2013 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Propagate = iota
	Request
	IAm
	IHave
	Call
	Recall
	Ping
	Pong
)

Variables

This section is empty.

Functions

func AddrConvUDP

func AddrConvUDP(str string) (net.Addr, error)

func HammingDistance

func HammingDistance(id1, id2 []byte) int

Calculates the hamming distance between 2 hashes

func IdDecode

func IdDecode(id string) ([]byte, error)

func IdEncode

func IdEncode(id []byte) string

Types

type AddrConv

type AddrConv func(str string) (net.Addr, error)

type Agent

type Agent struct {
	Socket   net.PacketConn
	Open     bool
	ReaderCh chan Cmd
	// contains filtered or unexported fields
}

func (*Agent) Call

func (a *Agent) Call(dest net.Addr)

func (*Agent) IAm

func (a *Agent) IAm(dest net.Addr, id string)

func (*Agent) IHave

func (a *Agent) IHave(dest net.Addr, id string)

func (*Agent) Ping

func (a *Agent) Ping(dest net.Addr, id string)

func (*Agent) Pong

func (a *Agent) Pong(dest net.Addr, id string)

func (*Agent) Propagate

func (a *Agent) Propagate(dest net.Addr, id string, addr net.Addr)

func (*Agent) Reader

func (a *Agent) Reader()

func (*Agent) Recall

func (a *Agent) Recall(dest net.Addr, passive net.Addr)

func (*Agent) Request

func (a *Agent) Request(dest net.Addr, ttl int64, id string, addr net.Addr)

type AgentThread

type AgentThread struct {
	OwnNodeID []byte
	MainList  Nlist
	NearList  Nlist
	Agent     Agent
	AddrConv  AddrConv
	Bucket    bucket.Bucket
	MaxTTL    int64
	// contains filtered or unexported fields
}

func (*AgentThread) Constructor

func (at *AgentThread) Constructor()

func (*AgentThread) Start

func (at *AgentThread) Start()

type Cmd

type Cmd struct {
	CmdId  int
	CmdPar []string
	Addr   net.Addr
}

type CmdRequest

type CmdRequest struct {
	Cmd  Cmd
	Id   []byte
	Addr net.Addr
}

type Nlist

type Nlist struct {
	OwnNodeID []byte
	MaxLen    int
	// contains filtered or unexported fields
}

func (*Nlist) Constructor

func (n *Nlist) Constructor() *Nlist

func (*Nlist) Insert

func (n *Nlist) Insert(id []byte, addr net.Addr) bool

func (*Nlist) InsertNode

func (n *Nlist) InsertNode(node *Node) bool

func (*Nlist) Iterate

func (n *Nlist) Iterate(dst chan *Node)

func (*Nlist) Len

func (n *Nlist) Len() int

func (*Nlist) Remove

func (n *Nlist) Remove() *Node

type Node

type Node struct {
	Id   []byte
	Addr net.Addr
}

type NodeMap

type NodeMap map[string]*Node

func (NodeMap) InsertNode

func (nm NodeMap) InsertNode(n *Node) bool

func (NodeMap) Iterate

func (nm NodeMap) Iterate(dst chan *Node)

func (NodeMap) RemoveNode

func (nm NodeMap) RemoveNode(n *Node)

Jump to

Keyboard shortcuts

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