nodes

package
v0.49.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveNodeIDsToFile

func SaveNodeIDsToFile(filePath string, nodeIDs []string) error

SaveNodeIDsToFile creates a new Nodes struct from node IDs and saves it to the specified path.

Types

type Nodes

type Nodes struct {
	Nodes map[string]struct{} `json:"nodes"`
}

Nodes represents a set of node IDs. This is used to keep track of which nodes are available for a given domain. This struct is serialized to JSON and stored in each domain directory in the `nodes.json` file

func LoadNodesFromFile

func LoadNodesFromFile(filePath string) (*Nodes, error)

LoadNodesFromFile loads nodes from a JSON file at the specified path.

func NewNodes

func NewNodes(nodeIDs []string) *Nodes

NewNodes creates a new Nodes struct with the given node IDs.

func (*Nodes) Add

func (n *Nodes) Add(nodeID string)

Add adds a node ID to the set. It is No-op if already exists.

func (*Nodes) Keys

func (n *Nodes) Keys() []string

Keys returns the node IDs as a slice.

func (*Nodes) SaveToFile

func (n *Nodes) SaveToFile(filePath string) error

SaveToFile saves the nodes to a JSON file at the specified path. If the file already exists, the new nodes will be merged with the existing nodes. If a node with the same id already exists, it will be overwritten.

Jump to

Keyboard shortcuts

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