node

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

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

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

Contains structures to describe insolar 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 insolar 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 ID

type ID []byte

ID is node id.

func NewID

func NewID() (ID, error)

NewID returns random node id.

func NewIDs

func NewIDs(num int) ([]ID, error)

NewIDs returns given number of random node ids.

func (ID) Equal

func (id ID) Equal(other ID) bool

Equal checks if id is equal to another.

func (ID) String

func (id ID) String() string

String is a base58-encoded string representation of node id.

type Node

type Node struct {
	// ID is a 20 byte unique identifier.
	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 insolar addresses match).

func (Node) String

func (node Node) String() string

String representation of Node.

type Origin

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

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

func NewOrigin

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

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

func (*Origin) Contains

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

Contains checks if origin node “contains” insolar 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