46 lines
1.3 KiB
Go
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")
|
|
}
|