node

package
v0.0.0-...-58ee6da Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

A node in the mesh, this is how we keep track of an individual peer. Due to a circular import SNAFU, this isn't part of the 'networking' package.

Used to track a node's status as encapsulated in Java's StatusResponse message content class. Informational purposes only, so some info duplication is OK here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Identifier     []byte // wallet public key (32 bytes)
	IpAddress      []byte // IPv4 address, stored as bytes to keep memory predictable (4 bytes)
	IpString       string // IP copy in string format for convenience
	PortTcp        int32  // TCP port number
	PortUdp        int32  // UDP port number, if available
	QueueTimestamp int64  // this is the timestamp that determines queue placement -- it is when the verifier joined the mesh or when the verifier was last updated
	Nickname       string // we keep those here too, no need to have a separate nickname manager IMO

	IdentifierChangeTimestamp int64 // when the identifier at this IP was last changed
	InactiveTimestamp         int64 // when the verifier was marked as inactive; -1 for active verifiers
	LastNodeJoinBlock         int64 // number of the last frozen edge block when we sent this node a node join message, set to 0 if it should receive a message

	FailedConnectionCount int // number of failed connection attempts to this node
}

func NewNode

func NewNode(id, ip []byte, portTcp, portUdp int32) *Node

Create a new node entry

func ReadNewNode

func ReadNewNode(r io.Reader) (*Node, error)

Convenience to create a new node from bytes

func (*Node) GetSerializedLength

func (n *Node) GetSerializedLength() int

Serializable Interface: How many bytes will ToBytes return?

func (*Node) Read

func (n *Node) Read(r io.Reader) error

Serializable Interface: Construct node info from bytes.

func (*Node) ToBytes

func (n *Node) ToBytes() []byte

Serializable Interface: Dump node info to bytes.

type Status

type Status struct {
	Identifier        []byte
	Timestamp         int64
	Ip                []byte
	Nickname          string
	Version           int
	MeshTotal         int
	MeshCycle         int
	CycleLength       int
	Transactions      int
	RetentionEdge     int64
	TrailingEdge      int64
	FrozenEdge        int64
	OpenEdge          int64
	BlocksTransmitted int64
	BlocksCreated     int64
	VoteStats         string
	LastJoinHeight    int64
	LastRemovalHeight int64
	ReceivingUDP      bool
}

func StatusFromStatusResponse

func StatusFromStatusResponse(identifier, ip []byte, timestamp int64, lines []string) *Status

Convert Java's nasty status response format to something more palpable.

Jump to

Keyboard shortcuts

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