Documentation ¶
Index ¶
Constants ¶
View Source
const K = 128
K is the default bucketSize
View Source
const N = 16
N is the default number of buckets
View Source
const NodeURLScheme = "vnode"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { PeerKey ed25519.PrivateKey DBPath string BootNodes []*Node Addr string NetID network.ID Self *Node }
Config is the essential configuration to create a Discovery implementation
type Discovery ¶
type Discovery interface { Start() error Stop() SubNodes(ch chan<- *Node, near bool) UnSubNodes(ch chan<- *Node) Mark(id NodeID, lifetime int64) UnMark(id NodeID) Block(id NodeID, ip net.IP) More(ch chan<- *Node, n int) Nodes() []string Delete(id NodeID) }
Discovery is the interface to discovery other node
type Message ¶
type Message interface { String() string // contains filtered or unexported methods }
type Node ¶
type Node struct { ID NodeID IP net.IP UDP uint16 TCP uint16 Net network.ID Ext []byte // contains filtered or unexported fields }
Node mean a node in vite P2P network
func (*Node) Deserialize ¶
Deserialize encoded data, []byte, to a Node, you must create the Node first, like following:
n := new(Node) err := n.Deserialize(buf)
func (*Node) String ¶
String marshal node to url-like string which looks like:
vnode://<hex node id> vnode://<hex node id>@<ip>:<udpPort>#<tcpPort>
type NodeID ¶
type NodeID [32]byte
NodeID use to mark node, and build a structural network
var ZERO_NODE_ID NodeID
ZERO_NODE_ID is the zero-value of NodeID type
func Bytes2NodeID ¶
Bytes2NodeID turn a slice to NodeID
func HexStr2NodeID ¶
HexStr2NodeID parse a hex coded string to NodeID
func Priv2NodeID ¶
func Priv2NodeID(priv ed25519.PrivateKey) (NodeID, error)
Priv2NodeID got the corresponding NodeID from ed25519.PeerKey
Source Files ¶
Click to show internal directories.
Click to hide internal directories.