relaxdht

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

This section is empty.

Variables

This section is empty.

Functions

func HammingDistance

func HammingDistance(id1, id2 []byte) int

Calculates the hamming distance between 2 hashes

func HammingDistanceRH

func HammingDistanceRH(id1 []byte, id2s string) (int, error)

func JsonGetField

func JsonGetField(json interface{}, field string) (interface{}, bool)

func JsonGetFieldString

func JsonGetFieldString(json interface{}, field string) (string, bool)

Types

type Contact

type Contact struct {
	Distance int
	Id       string
	Addr     net.Addr
}

type ContactTable

type ContactTable struct {
	Data []Contact
	// contains filtered or unexported fields
}

func (*ContactTable) Debug

func (c *ContactTable) Debug()

func (*ContactTable) GetCloser

func (c *ContactTable) GetCloser(ids string, od int) <-chan net.Addr

func (*ContactTable) GetClosest

func (c *ContactTable) GetClosest(id []byte) (Contact, int, bool)

func (*ContactTable) Insert

func (c *ContactTable) Insert(con Contact)

func (*ContactTable) Len

func (c *ContactTable) Len() int

func (*ContactTable) Less

func (c *ContactTable) Less(i, j int) bool

func (*ContactTable) Limit

func (c *ContactTable) Limit(n int)

func (*ContactTable) SLimit

func (c *ContactTable) SLimit(n int)

func (*ContactTable) SearchId

func (c *ContactTable) SearchId(id string) (bool, int)

func (*ContactTable) Sort

func (c *ContactTable) Sort()

func (*ContactTable) Swap

func (c *ContactTable) Swap(i, j int)

type IHaveMsg

type IHaveMsg struct {
	Id   []byte
	Addr *net.TCPAddr
}

type Node

type Node struct {
	Conn              net.PacketConn
	Id                []byte
	IdEnc             string
	Table             *ContactTable
	IHCh              chan *IHaveMsg
	Bucket            bucket.Bucket
	BucketServicePort string
	Debug             bool
}

func CreateNode

func CreateNode(conn net.PacketConn, id []byte) *Node

func (*Node) BroadSearch

func (n *Node) BroadSearch(id []byte)

func (*Node) Exists

func (n *Node) Exists(hash []byte) bool

func (*Node) Ping

func (n *Node) Ping(addr net.Addr)

func (*Node) Push

func (n *Node) Push(hash []byte)

func (*Node) Recommend

func (n *Node) Recommend(addr, other net.Addr)

func (*Node) Run

func (n *Node) Run()

func (*Node) Search

func (n *Node) Search(id []byte)

type Packet

type Packet struct {
	Id       string      `json:"id"`
	Q        string      `json:"q"`
	OtherId  string      `json:"other-id,omitempty"`
	Appendix interface{} `json:"appendix,omitempty"`
	TTL      string      `json"ttl,omitempty"`
}

Jump to

Keyboard shortcuts

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