node

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: Unlicense Imports: 10 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, identitky 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 nonce.ID
	sync.Mutex
	AddrPort  *netip.AddrPort
	Identity  *crypto.Keys
	RelayRate uint32            // Base relay price mSAT/Mb.
	Services  services.Services // Services offered by this peer.
	Load      byte
	payments.PayChan
	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) 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