tmpnet

package
v1.21.8 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNetworkTimeout = 2 * time.Minute
)

Variables

This section is empty.

Functions

func GetDefaultNetworkID added in v1.16.56

func GetDefaultNetworkID() uint32

GetDefaultNetworkID returns the default network ID for testing

func NewTestGenesisWithFunds added in v1.1.11

func NewTestGenesisWithFunds(
	networkID uint32,
	nodes []*Node,
	fundedKeys []*secp256k1.PrivateKey,
) ([]byte, error)

NewTestGenesisWithFunds creates a test genesis configuration with funded accounts

func ValidateGenesis added in v1.16.56

func ValidateGenesis(genesisBytes []byte) error

ValidateGenesis validates a genesis configuration

Types

type Allocation added in v1.16.56

type Allocation struct {
	ETHAddr        string         `json:"ethAddr"`
	LUXAddr        string         `json:"luxAddr"`
	InitialAmount  uint64         `json:"initialAmount"`
	UnlockSchedule []UnlockPeriod `json:"unlockSchedule,omitempty"`
}

Allocation represents an initial fund allocation

type Chain

type Chain struct {
	ChainID   ids.ID
	VMID      ids.ID
	ChainName string
	Genesis   []byte
}

Chain represents a blockchain in a subnet

type GenesisConfig added in v1.16.56

type GenesisConfig struct {
	NetworkID                  uint32       `json:"networkID"`
	Allocations                []Allocation `json:"allocations"`
	StartTime                  uint64       `json:"startTime"`
	InitialStakeDuration       uint64       `json:"initialStakeDuration"`
	InitialStakeDurationOffset uint64       `json:"initialStakeDurationOffset"`
	InitialStakedFunds         []string     `json:"initialStakedFunds"`
	InitialStakers             []Staker     `json:"initialStakers"`
	CChainGenesis              string       `json:"cChainGenesis"`
	Message                    string       `json:"message"`
}

GenesisConfig represents genesis configuration

type Network

type Network struct {
	UUID                 string
	NetworkID            uint32
	Owner                string
	Dir                  string
	Nodes                []*Node
	DefaultRuntimeConfig NodeRuntimeConfig
	Genesis              []byte

	// Track subnets/chains
	Subnets []*Subnet
}

Network represents a local test network

func ReadNetwork

func ReadNetwork(ctx context.Context, log log.Logger, networkDir string) (*Network, error)

ReadNetwork reads a network from its directory

func (*Network) GetBootstrapIPsAndIDs

func (n *Network) GetBootstrapIPsAndIDs() ([]string, []string)

GetBootstrapIPsAndIDs returns the bootstrap IPs and IDs for the network

func (*Network) Start added in v1.16.56

func (n *Network) Start(ctx context.Context, log log.Logger) error

Start starts all nodes in the network

func (*Network) Stop

func (n *Network) Stop(ctx context.Context) error

Stop stops all nodes in the network

func (*Network) Write

func (n *Network) Write() error

Write writes the network configuration to disk

type Node

type Node struct {
	NodeID        ids.NodeID
	URI           string
	StakingPort   uint64
	HTTPPort      uint64
	DataDir       string
	RuntimeConfig *NodeRuntimeConfig
	Flags         map[string]interface{}

	// BLS signing key
	SigningKey *bls.SecretKey

	// Staking credentials
	StakingKey  []byte
	StakingCert []byte
	// contains filtered or unexported fields
}

Node represents a node in a local test network

func NewNode

func NewNode() *Node

NewNode creates a new node with default configuration

func ReadNode added in v1.1.11

func ReadNode(nodeDir string) (*Node, error)

ReadNode reads a node configuration from its directory

func (*Node) GetURI added in v1.16.56

func (n *Node) GetURI() string

GetURI returns the node's HTTP URI

func (*Node) IsRunning

func (n *Node) IsRunning() bool

IsRunning returns true if the node process is running

func (*Node) Start

func (n *Node) Start(ctx context.Context, log log.Logger) error

Start starts the node process

func (*Node) Stop

func (n *Node) Stop(ctx context.Context) error

Stop stops the node process

func (*Node) Write

func (n *Node) Write() error

Write writes the node configuration to disk

type NodeConfig added in v1.1.11

type NodeConfig struct {
	NodeID      string                 `json:"nodeID"`
	URI         string                 `json:"uri"`
	StakingPort uint64                 `json:"stakingPort"`
	HTTPPort    uint64                 `json:"httpPort"`
	DataDir     string                 `json:"dataDir"`
	Flags       map[string]interface{} `json:"flags"`
}

NodeConfig is the serialized node configuration

type NodeRuntimeConfig

type NodeRuntimeConfig struct {
	Process *ProcessRuntimeConfig
}

NodeRuntimeConfig configures how nodes are run

type ProcessRuntimeConfig

type ProcessRuntimeConfig struct {
	LuxdPath string
}

ProcessRuntimeConfig configures process execution

type Staker added in v1.16.56

type Staker struct {
	NodeID        string `json:"nodeID"`
	RewardAddress string `json:"rewardAddress"`
	DelegationFee uint32 `json:"delegationFee"`
}

Staker represents an initial staker

type Subnet

type Subnet struct {
	SubnetID     ids.ID
	Chains       []*Chain
	ValidatorIDs []ids.NodeID
}

Subnet represents a subnet in the network

type UnlockPeriod added in v1.16.56

type UnlockPeriod struct {
	Amount   uint64 `json:"amount"`
	Locktime uint64 `json:"locktime"`
}

UnlockPeriod represents a vesting unlock period

Jump to

Keyboard shortcuts

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