node

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// A node's name must be unique from all other nodes
	// in a network. If Name is the empty string, a
	// unique name is assigned on node creation.
	Name string `json:"name"`
	// True if other nodes should use this node
	// as a bootstrap beacon.
	IsBeacon bool `json:"isBeacon"`
	// Must not be nil.
	StakingKey string `json:"stakingKey"`
	// Must not be nil.
	StakingCert string `json:"stakingCert"`
	// May be nil.
	ConfigFile string `json:"configFile"`
	// May be nil.
	CChainConfigFile string `json:"cChainConfigFile"`
	// Flags can hold additional flags for the node.
	// It can be empty.
	// The precedence of flags handling is:
	// 1. Flags defined in node.Config (this struct) override
	// 2. Flags defined in network.Config override
	// 3. Flags defined in the json config file
	Flags map[string]interface{} `json:"flags"`
	// What type of node this is
	BinaryPath string `json:"binaryPath"`
	// If non-nil, direct this node's Stdout to os.Stdout
	RedirectStdout bool `json:"redirectStdout"`
	// If non-nil, direct this node's Stderr to os.Stderr
	RedirectStderr bool `json:"redirectStderr"`
}

Config encapsulates an avalanchego configuration

func (*Config) Validate

func (c *Config) Validate(expectedNetworkID uint32) error

Validate returns an error if this config is invalid

type Node

type Node interface {
	// Return this node's name, which is unique
	// across all the nodes in its network.
	GetName() string
	// Return this node's Avalanche node ID.
	GetNodeID() ids.ShortID
	// Return a client that can be used to make API calls.
	GetAPIClient() api.Client
	// Return this node's IP (e.g. 127.0.0.1).
	GetURL() string
	// Return this node's P2P (staking) port.
	GetP2PPort() uint16
	// Return this node's HTP API port.
	GetAPIPort() uint16
	// Starts a new test peer, connects it to the given node, and returns the peer.
	// [handler] defines how the test peer handles messages it receives.
	// The test peer can be used to send messages to the node it's attached to.
	// It's left to the caller to maintain a reference to the returned peer.
	// The caller should call StartClose() on the peer when they're done with it.
	AttachPeer(ctx context.Context, handler router.InboundHandler) (peer.Peer, error)
}

Node represents an AvalancheGo node

Jump to

Keyboard shortcuts

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