node

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package node is a fundamental part of networking system. Each node has:

  • one real network address (IP or any other transport protocol address)
  • multiple abstract network IDs (either node's own or ones belonging to relayed nodes)

Contains structures to describe network entities in code.

Usage:

 	originAddress, err := node.NewAddress(address)
	if err != nil {
		...
	}

	origin, err := node.NewOrigin(nil, originAddress)
	if err != nil {
		...
	}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	net.UDPAddr
}

Address is node's real network address.

func NewAddress

func NewAddress(address string) (*Address, error)

NewAddress is constructor.

func (Address) Equal

func (address Address) Equal(other Address) bool

Equal checks if address is equal to another.

type Node

type Node struct {
	// ID is a 20 byte unique identifier.
	ID id.ID

	// Address is IP and port.
	Address *Address
}

Node is the over-the-wire representation of a node.

func NewNode

func NewNode(address *Address) *Node

NewNode creates a new Node for bootstrapping.

func (Node) Equal

func (node Node) Equal(other Node) bool

Equal checks if node equals to other node (e.g. nodes' IDs and network addresses match).

func (Node) String

func (node Node) String() string

String representation of Node.

type Origin

type Origin struct {
	IDs     []id.ID
	Address *Address
}

Origin is “self” variant of Node. Unlike ordinary node it can have multiple IDs.

func NewOrigin

func NewOrigin(ids []id.ID, address *Address) (*Origin, error)

NewOrigin creates origin node from list of ids and network address.

func (*Origin) Contains

func (s *Origin) Contains(node *Node) bool

Contains checks if origin node “contains” network node. It checks if node's and origin's addresses match and node's id is in origin's ids list.

Jump to

Keyboard shortcuts

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