discovery

package
v0.0.0-...-96daba7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

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

func New

func New(peerKey ed25519.PrivateKey, node *vnode.Node, bootNodes, bootSeeds []string, listenAddress string, db NodeDB) *Discovery

New create a Discovery implementation

func (*Discovery) Delete

func (d *Discovery) Delete(id vnode.NodeID, reason error)

func (*Discovery) GetNodes

func (d *Discovery) GetNodes(count int) (nodes []*vnode.Node)

func (*Discovery) Nodes

func (d *Discovery) Nodes() []*vnode.Node

func (*Discovery) Resolve

func (d *Discovery) Resolve(id vnode.NodeID) (ret *vnode.Node)

func (*Discovery) SetFinder

func (d *Discovery) SetFinder(f Finder)

func (*Discovery) Start

func (d *Discovery) Start() (err error)

func (*Discovery) Stop

func (d *Discovery) Stop() (err error)

func (*Discovery) SubscribeNode

func (d *Discovery) SubscribeNode(receiver func(n *vnode.Node)) (subId int)

func (*Discovery) Unsubscribe

func (d *Discovery) Unsubscribe(subId int)

type Finder

type Finder interface {
	Observer
	SetResolver(discv interface {
		GetNodes(count int) (nodes []*vnode.Node)
	})
	FindNeighbors(fromId, target vnode.NodeID, count int) []*vnode.EndPoint
}

type Node

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

type NodeDB

type NodeDB interface {
	StoreNode(node *vnode.Node) (err error)
	RemoveNode(id vnode.NodeID)
	ReadNodes(expiration int64) []*vnode.Node
	RetrieveActiveAt(id vnode.NodeID) int64
	StoreActiveAt(id vnode.NodeID, v int64)
	RetrieveCheckAt(id vnode.NodeID) int64
	StoreCheckAt(id vnode.NodeID, v int64)
	Close() error
	Clean(expiration int64)
}

type Observer

type Observer interface {
	Sub(sub Subscriber)
	UnSub(sub Subscriber)
}

type Request

type Request struct {
	Node  *vnode.Node `json:"node"`
	Count int         `json:"count"`
}

type Result

type Result struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Data    []string `json:"data"`
}

type Subscriber

type Subscriber interface {
	// Sub return the unique id
	Sub(receiver func(n *vnode.Node)) (subId int)
	// UnSub received the id returned by Sub
	UnSub(subId int)
}

Subscriber can be subscribed by observer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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