node

package
v1.4.9 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: BSD-3-Clause Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP = "tcp"
)

Networking constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	genesis.Params

	// If true, bootstrap the current database version and then end the node.
	FetchOnly bool

	// Genesis information
	GenesisBytes []byte
	AvaxAssetID  ids.ID

	// protocol to use for opening the network interface
	Nat nat.Router

	// Attempted NAT Traversal did we attempt
	AttemptedNATTraversal bool

	// ID of the network this node should connect to
	NetworkID uint32

	// Assertions configuration
	EnableAssertions bool

	// Crypto configuration
	EnableCrypto bool

	// Path to database
	DBPath string

	// If false, uses an in memory database
	DBEnabled bool

	// Staking configuration
	StakingIP             utils.DynamicIPDesc
	EnableStaking         bool
	StakingTLSCert        tls.Certificate
	DisabledStakingWeight uint64

	// Throttling
	MaxNonStakerPendingMsgs uint32
	StakerMSGPortion        float64
	StakerCPUPortion        float64
	SendQueueSize           uint32
	MaxPendingMsgs          uint32

	// Health
	HealthCheckFreq time.Duration

	// Network configuration
	NetworkConfig       timer.AdaptiveTimeoutConfig
	NetworkHealthConfig network.HealthConfig
	PeerListSize        uint32
	PeerListGossipSize  uint32
	PeerListGossipFreq  time.Duration
	DialerConfig        network.DialerConfig

	// Benchlist Configuration
	BenchlistConfig benchlist.Config

	// Bootstrapping configuration
	BootstrapIDs []ids.ShortID
	BootstrapIPs []utils.IPDesc

	// HTTP configuration
	HTTPHost string
	HTTPPort uint16

	HTTPSEnabled        bool
	HTTPSKeyFile        string
	HTTPSCertFile       string
	APIRequireAuthToken bool
	APIAuthPassword     string
	APIAllowedOrigins   []string

	// Enable/Disable APIs
	AdminAPIEnabled    bool
	InfoAPIEnabled     bool
	KeystoreAPIEnabled bool
	MetricsAPIEnabled  bool
	HealthAPIEnabled   bool
	IndexAPIEnabled    bool

	// Profiling configurations
	ProfilerConfig profiler.Config

	// Logging configuration
	LoggingConfig logging.Config

	// Plugin directory
	PluginDir string

	// Consensus configuration
	ConsensusParams avalanche.Parameters

	// IPC configuration
	IPCAPIEnabled      bool
	IPCPath            string
	IPCDefaultChainIDs []string

	// Metrics
	MeterVMEnabled bool

	// Router that is used to handle incoming consensus messages
	ConsensusRouter          router.Router
	RouterHealthConfig       router.HealthConfig
	ConsensusShutdownTimeout time.Duration
	ConsensusGossipFrequency time.Duration
	// Number of peers to gossip to when gossiping accepted frontier
	ConsensusGossipAcceptedFrontierSize uint
	// Number of peers to gossip each accepted container to
	ConsensusGossipOnAcceptSize uint

	// Dynamic Update duration for IP or NAT traversal
	DynamicUpdateDuration time.Duration

	DynamicPublicIPResolver dynamicip.Resolver

	// Throttling incoming connections
	ConnMeterResetDuration time.Duration
	ConnMeterMaxConns      int

	// Subnet Whitelist
	WhitelistedSubnets ids.Set

	IndexAllowIncomplete bool

	// Should Bootstrap be retried
	RetryBootstrap bool

	// Max number of times to retry bootstrap
	RetryBootstrapMaxAttempts int

	// Timeout when connecting to bootstrapping beacons
	BootstrapBeaconConnectionTimeout time.Duration

	// Max number of containers in a multiput message sent by this node.
	BootstrapMultiputMaxContainersSent int

	// This node will only consider the first [MultiputMaxContainersReceived]
	// containers in a multiput it receives.
	BootstrapMultiputMaxContainersReceived int

	// Peer alias configuration
	PeerAliasTimeout time.Duration

	// ChainConfigs
	ChainConfigs map[string]chains.ChainConfig

	// Max time to spend fetching a container and its
	// ancestors while responding to a GetAncestors message
	BootstrapMaxTimeGetAncestors time.Duration
}

Config contains all of the configurations of an Avalanche node.

type Node

type Node struct {
	Log        logging.Logger
	LogFactory logging.Factory
	HTTPLog    logging.Logger

	// This node's unique ID used when communicating with other nodes
	// (in consensus, for example)
	ID ids.ShortID

	// Storage for this node
	DBManager manager.Manager
	DB        database.Database

	// dispatcher for events as they happen in consensus
	DecisionDispatcher  *triggers.EventDispatcher
	ConsensusDispatcher *triggers.EventDispatcher

	IPCs *ipcs.ChainIPCs

	// Net runs the networking stack
	Net network.Network

	// Handles HTTP API calls
	APIServer server.Server

	// This node's configuration
	Config *Config

	// Incremented only once on initialization.
	// Decremented when node is done shutting down.
	DoneShuttingDown sync.WaitGroup
	// contains filtered or unexported fields
}

Node is an instance of an Avalanche node.

func (*Node) Dispatch

func (n *Node) Dispatch() error

Dispatch starts the node's servers. Returns when the node exits.

func (*Node) ExitCode

func (n *Node) ExitCode() int

func (*Node) Initialize

func (n *Node) Initialize(
	config *Config,
	dbManager manager.Manager,
	logger logging.Logger,
	logFactory logging.Factory,
) error

Initialize this node

func (*Node) Shutdown

func (n *Node) Shutdown(exitCode int)

Shutdown this node May be called multiple times

Jump to

Keyboard shortcuts

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