node

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

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"`
	// Must not be nil.
	StakingSigningKey string `json:"stakingSigningKey"`
	// May be nil.
	ConfigFile string `json:"configFile"`
	// May be nil.
	ChainConfigFiles map[string]string `json:"chainConfigFiles"`
	// May be nil.
	UpgradeConfigFiles map[string]string `json:"upgradeConfigFiles"`
	// May be nil.
	SubnetConfigFiles map[string]string `json:"subnetConfigFiles"`
	// 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.NodeID
	// 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 HTTP 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)
	// Sends a message  from the attached peer to the node
	SendOutboundMessage(ctx context.Context, peerID string, content []byte, op uint32) (bool, error)
	// Return the state of the node process
	Status() status.Status
	// Return this node's avalanchego binary path
	GetBinaryPath() string
	// Return this node's db dir
	GetDbDir() string
	// Return this node's logs dir
	GetLogsDir() string
	// Return this node's build dir
	GetBuildDir() string
	// Return this node's config file contents
	GetConfigFile() string
	// Return this node's config
	GetConfig() Config
	// Return this node's flag value
	GetFlag(string) (string, error)
}

Node represents an AvalancheGo node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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