node

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 13 Imported by: 0

Documentation

Overview

Package node is a specification for the in-memory metadata related to an indra network peer.

This structure aggregates the address, identity keys, relay rate, services and payments channel for the peer.

Index

Constants

View Source
const (
	// PaymentChanBuffers is the default number of buffers used in a payment channel.
	PaymentChanBuffers = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {

	// ID is a unique identifier used internally for references.
	ID nonce.ID

	// Mutex to stop concurrent read/write.
	*sync.Mutex

	// Addresses is the network addresses a node is listening to.
	//
	// These can be multiple, but for reasons of complexity, they are filtered by the available protocols for the session manager, ie ip4 always, ip6 sometimes.
	Addresses []*netip.AddrPort

	// Identity is the crypto.Keys identifying the node on the Indra network.
	Identity *crypto.Keys

	// RelayRate is the base relay price mSAT/Mb.
	RelayRate uint32

	// Services offered by this peer.
	Services services.Services

	// Load is the current level of utilisation of the node's resources.
	Load byte

	// PayChan is the channel that payments to this node are sent/received on (internal/external node).
	payments.PayChan

	// Transport is the way to contact the node. Sending messages on this channel go
	// to the dispatcher to be segmented and delivered, or conversely assembled and
	// received.
	Transport tpt.Transport
}

Node is a representation of a messaging counterparty.

func NewNode

func NewNode(addr []*netip.AddrPort, keys *crypto.Keys, tpt tpt.Transport,
	relayRate uint32) (n *Node, id nonce.ID)

NewNode creates a new Node. The transport should be from either dialing out or a peer dialing in and the self model does not need to do this.

func (*Node) AddService

func (n *Node) AddService(s *services.Service) (e error)

AddService adds a service to a Node.

func (*Node) DeleteService

func (n *Node) DeleteService(port uint16)

DeleteService removes a service from a Node.

func (*Node) FindService

func (n *Node) FindService(port uint16) (svc *services.Service)

FindService searches for a local service with a given port number.

func (*Node) PickAddress added in v0.1.19

func (n *Node) PickAddress(p protocols.NetworkProtocols) (ma multiaddr.Multiaddr)

func (*Node) ReceiveFrom

func (n *Node) ReceiveFrom(port uint16) (b <-chan slice.Bytes)

ReceiveFrom returns the channel that receives messages for a given port.

func (*Node) SendTo

func (n *Node) SendTo(port uint16, b slice.Bytes) (e error)

SendTo delivers a message to a service identified by its port.

Jump to

Keyboard shortcuts

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