Mining/cmd/mining/cmd/start.go
Virgil f3709678cc
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Apply AX naming and comment cleanup
2026-04-04 08:01:20 +00:00

46 lines
1.3 KiB
Go

package cmd
import (
"context"
"fmt"
"forge.lthn.ai/Snider/Mining/pkg/mining"
"github.com/spf13/cobra"
)
var (
poolAddress string
walletAddress string
)
// mining start xmrig --pool stratum+tcp://pool.example.com:3333 --wallet 44Affq5kSiGBoZ... starts a miner with explicit pool and wallet values.
var startCmd = &cobra.Command{
Use: "start <miner-type>",
Short: "Start a new miner",
Long: `Start a miner with an explicit pool URL and wallet address.`,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
minerType := args[0]
minerConfig := &mining.Config{
Pool: poolAddress,
Wallet: walletAddress,
}
miner, err := getSharedManager().StartMiner(context.Background(), minerType, minerConfig)
if err != nil {
return fmt.Errorf("failed to start miner: %w", err)
}
fmt.Printf("Miner started successfully:\n")
fmt.Printf(" Name: %s\n", miner.GetName())
return nil
},
}
func init() {
rootCmd.AddCommand(startCmd)
startCmd.Flags().StringVarP(&poolAddress, "pool", "p", "", "Mining pool URL, for example stratum+tcp://pool.example.com:3333")
startCmd.Flags().StringVarP(&walletAddress, "wallet", "w", "", "Wallet address, for example 44Affq5kSiGBoZ...")
_ = startCmd.MarkFlagRequired("pool")
_ = startCmd.MarkFlagRequired("wallet")
}