Files
cli/cmd/flags/local_machine.go
zeekayandHanzo Dev 15d4ed2eb5 A validator syncs the whole primary network
The CLI set --partial-sync-primary-network on every validator it brought
up, and defaulted the flag to true. luxd no longer has the mode: the
primary network's chains are one validator set, and a node that syncs
only the P-Chain casts no vote on the rest. The flag, the template line
that emitted it, and the remote-config round trip that read it back are
gone.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-03 13:46:48 -07:00

76 lines
2.9 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package flags
import (
"fmt"
"github.com/luxfi/constants"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const (
useLocalMachineFlag = "use-local-machine"
httpPortFlag = "http-port"
stakingPortFlag = "staking-port"
luxdPathFlag = "luxd-path"
luxdVersionFlag = "luxd-version"
stakingTLSKeyPathFlag = "staking-tls-key-path"
stakingCertKeyPathFlag = "staking-cert-key-path"
stakingSignerKeyPathFlag = "staking-signer-key-path"
)
type LocalMachineFlags struct {
UseLocalMachine bool
HTTPPorts []uint
StakingPorts []uint
LuxdBinaryPath string
UserProvidedLuxdVersion string
StakingTLSKeyPaths []string
StakingCertKeyPaths []string
StakingSignerKeyPaths []string
}
func validateLocalMachineFlags(localMachineFlags LocalMachineFlags) error {
if len(localMachineFlags.StakingSignerKeyPaths) != len(localMachineFlags.StakingCertKeyPaths) || len(localMachineFlags.StakingSignerKeyPaths) != len(localMachineFlags.StakingTLSKeyPaths) {
return fmt.Errorf("staking key inputs must be for the same number of nodes")
}
return nil
}
func AddLocalMachineFlagsToCmd(cmd *cobra.Command, localMachineFlags *LocalMachineFlags) GroupedFlags {
return RegisterFlagGroup(cmd, "Local Machine Flags (Use Local Machine as Bootstrap Validator)", "show-local-machine-flags", true, func(set *pflag.FlagSet) {
set.BoolVar(&localMachineFlags.UseLocalMachine, useLocalMachineFlag, false, "use local machine as a blockchain validator")
set.UintSliceVar(&localMachineFlags.HTTPPorts, httpPortFlag, []uint{}, "http port for node(s)")
set.UintSliceVar(&localMachineFlags.StakingPorts, stakingPortFlag, []uint{}, "staking port for node(s)")
set.StringVar(&localMachineFlags.LuxdBinaryPath, luxdPathFlag, "", "use this luxd binary path")
set.StringVar(
&localMachineFlags.UserProvidedLuxdVersion,
luxdVersionFlag,
constants.DefaultLuxdVersion,
"use this version of luxd (ex: v1.17.12)",
)
set.StringSliceVar(&localMachineFlags.StakingTLSKeyPaths, stakingTLSKeyPathFlag, []string{}, "path to provided staking TLS key for node(s)")
set.StringSliceVar(&localMachineFlags.StakingCertKeyPaths, stakingCertKeyPathFlag, []string{}, "path to provided staking cert key for node(s)")
set.StringSliceVar(&localMachineFlags.StakingSignerKeyPaths, stakingSignerKeyPathFlag, []string{}, "path to provided staking signer key for node(s)")
localMachinePreRun := func(_ *cobra.Command, _ []string) error {
if err := validateLocalMachineFlags(*localMachineFlags); err != nil {
return err
}
return nil
}
existingPreRunE := cmd.PreRunE
cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
if existingPreRunE != nil {
if err := existingPreRunE(cmd, args); err != nil {
return err
}
}
return localMachinePreRun(cmd, args)
}
})
}