node

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWaitTimedOut = errors.New("waiting for all nodes timed out")
)

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a structure holding all the settings to configure a Gossamer node.

func New

func New(t *testing.T, tomlConfig cfg.Config,
	options ...Option) (node Node)

New returns a node configured using the toml configuration and options given.

func (*Node) Init

func (n *Node) Init() (err error)

Init initialises the Gossamer node.

func (Node) InitAndStartTest

func (n Node) InitAndStartTest(ctx context.Context, t *testing.T,
	signalTestToStop context.CancelFunc)

InitAndStartTest is a test helper method to initialise and start the node, as well as registering appriopriate test handlers. If initialising or starting fails, cleanup is done and the test fails instantly. If the node crashes during runtime, the passed `signalTestToStop` argument is called since the test cannot be failed from outside the main test goroutine.

func (Node) Key

func (n Node) Key() (key string)

Key returns the key of the node.

func (Node) RPCPort

func (n Node) RPCPort() (port string)

RPCPort returns the rpc port of the node.

func (*Node) Start

func (n *Node) Start(ctx context.Context) (runtimeError <-chan error, startErr error)

Start starts a Gossamer node using the node configuration of the receiving struct. It returns a start error if the node cannot be started, and runs the node until the context gets canceled. When the node crashes or is stopped, an error (nil or not) is sent in the waitErrCh.

func (*Node) StartAndWait

func (n *Node) StartAndWait(ctx context.Context) (
	runtimeError <-chan error, startErr error)

StartAndWait starts a Gossamer node using the node configuration of the receiving struct. It returns a start error if the node cannot be started, and runs the node until the context gets canceled. When the node crashes or is stopped, an error (nil or not) is sent in the waitErrCh. It waits for the node to respond to an RPC health call before returning.

func (Node) String

func (n Node) String() string

func (Node) WSPort

func (n Node) WSPort() (port string)

WSPort returns the websocket port of the node.

type Nodes

type Nodes []Node

Nodes is a slice of nodes.

func MakeNodes

func MakeNodes(t *testing.T, num int, tomlConfig cfg.Config,
	options ...Option) (nodes Nodes)

MakeNodes creates `num` nodes using the `tomlConfig` as a base config for each node. It overrides some of configuration: - the index of each node is incremented per node (overrides the SetIndex option, if set)

func (Nodes) Init

func (nodes Nodes) Init() (err error)

Init initialises all nodes and returns an error if any init operation failed.

func (Nodes) InitAndStartTest

func (nodes Nodes) InitAndStartTest(ctx context.Context, t *testing.T,
	signalTestToStop context.CancelFunc)

InitAndStartTest is a test helper method to initialise and start nodes, as well as registering appriopriate test handlers. If any node fails to initialise or start, cleanup is done and the test is instantly failed. If any node crashes at runtime, all other nodes are shutdown, cleanup is done and the passed argument `signalTestToStop` is called to signal to the main test goroutine to stop.

func (Nodes) Start

func (nodes Nodes) Start(ctx context.Context) (
	runtimeErrors []<-chan error, startErr error)

Start starts all the nodes and returns the number of started nodes and an eventual start error. The started number should be used by the caller to wait for `started` errors coming from the wait error channel. All the nodes are stopped when the context is canceled, and `started` errors will be sent in the waitErr channel.

type Option

type Option func(node *Node)

Option is an option to use with the `New` constructor.

func SetIndex

func SetIndex(index int) Option

SetIndex sets the index for the node.

func SetWriter

func SetWriter(writer io.Writer) Option

SetWriter sets the writer for the node.

Jump to

Keyboard shortcuts

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