Refine AX naming in mining CLI
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Virgil 2026-04-04 07:54:34 +00:00
parent 6864e52ed4
commit 6964d7ce5a
3 changed files with 41 additions and 41 deletions

View file

@ -269,13 +269,13 @@ var remotePingCmd = &cobra.Command{
var successfulPings int
for i := 0; i < count; i++ {
rtt, err := remoteController.PingPeer(selectedPeer.ID)
roundTripMillis, err := remoteController.PingPeer(selectedPeer.ID)
if err != nil {
fmt.Printf(" Ping %d: timeout\n", i+1)
continue
}
fmt.Printf(" Ping %d: %.2f ms\n", i+1, rtt)
totalRoundTripMillis += rtt
fmt.Printf(" Ping %d: %.2f ms\n", i+1, roundTripMillis)
totalRoundTripMillis += roundTripMillis
successfulPings++
if i < count-1 {
@ -296,29 +296,29 @@ var remotePingCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(remoteCmd)
// remoteCmd.AddCommand(remoteStatusCmd) // remote status peer-19f3 prints one peer, while `remote status` prints the fleet.
// remote status peer-19f3 prints one peer, while `remote status` prints the fleet.
remoteCmd.AddCommand(remoteStatusCmd)
// remoteCmd.AddCommand(remoteStartCmd) // remote start peer-19f3 --type xmrig --profile default launches a miner.
// remote start peer-19f3 --type xmrig --profile default launches a miner.
remoteCmd.AddCommand(remoteStartCmd)
remoteStartCmd.Flags().StringP("profile", "p", "", "Profile ID to start, for example default or office-rig")
remoteStartCmd.Flags().StringP("type", "t", "", "Miner type to start, for example xmrig or tt-miner")
// remoteCmd.AddCommand(remoteStopCmd) // remote stop peer-19f3 xmrig-main stops the selected miner.
// remote stop peer-19f3 xmrig-main stops the selected miner.
remoteCmd.AddCommand(remoteStopCmd)
remoteStopCmd.Flags().StringP("miner", "m", "", "Miner name to stop, for example xmrig-main")
// remoteCmd.AddCommand(remoteLogsCmd) // remote logs peer-19f3 xmrig-main prints miner logs.
// remote logs peer-19f3 xmrig-main prints miner logs.
remoteCmd.AddCommand(remoteLogsCmd)
remoteLogsCmd.Flags().IntP("lines", "n", 100, "Number of log lines to retrieve, for example 100")
// remoteCmd.AddCommand(remoteConnectCmd) // remote connect peer-19f3 opens the peer connection.
// remote connect peer-19f3 opens the peer connection.
remoteCmd.AddCommand(remoteConnectCmd)
// remoteCmd.AddCommand(remoteDisconnectCmd) // remote disconnect peer-19f3 closes the peer connection.
// remote disconnect peer-19f3 closes the peer connection.
remoteCmd.AddCommand(remoteDisconnectCmd)
// remoteCmd.AddCommand(remotePingCmd) // remote ping peer-19f3 --count 4 measures latency.
// remote ping peer-19f3 --count 4 measures latency.
remoteCmd.AddCommand(remotePingCmd)
remotePingCmd.Flags().IntP("count", "c", 4, "Number of ping samples to send, for example 4")
}
@ -364,13 +364,13 @@ func findPeerByPartialID(partialID string) *node.Peer {
}
// peerRegistry.ListPeers() falls back to partial IDs such as `peer-19`.
for _, peer := range peerRegistry.ListPeers() {
if strings.HasPrefix(peer.ID, partialID) {
return peer
for _, registeredPeer := range peerRegistry.ListPeers() {
if strings.HasPrefix(registeredPeer.ID, partialID) {
return registeredPeer
}
// strings.EqualFold(peer.Name, "office-rig") matches peers by display name as well as ID prefix.
if strings.EqualFold(peer.Name, partialID) {
return peer
// strings.EqualFold(registeredPeer.Name, "office-rig") matches peers by display name as well as ID prefix.
if strings.EqualFold(registeredPeer.Name, partialID) {
return registeredPeer
}
}
@ -397,10 +397,10 @@ func printPeerStats(peer *node.Peer, stats *node.StatsPayload) {
}
// formatDuration(90*time.Minute) // returns "1h 30m"
func formatDuration(d time.Duration) string {
days := int(d.Hours() / 24)
hours := int(d.Hours()) % 24
minutes := int(d.Minutes()) % 60
func formatDuration(duration time.Duration) string {
days := int(duration.Hours() / 24)
hours := int(duration.Hours()) % 24
minutes := int(duration.Minutes()) % 60
if days > 0 {
return fmt.Sprintf("%dd %dh %dm", days, hours, minutes)

View file

@ -31,15 +31,15 @@ var serveCmd = &cobra.Command{
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
displayHostName := serveHost
if displayHostName == "0.0.0.0" {
displayHost := serveHost
if displayHost == "0.0.0.0" {
var err error
displayHostName, err = getLocalIP()
displayHost, err = getLocalIP()
if err != nil {
displayHostName = "localhost"
displayHost = "localhost"
}
}
displayAddress := fmt.Sprintf("%s:%d", displayHostName, servePort)
displayAddress := fmt.Sprintf("%s:%d", displayHost, servePort)
listenAddress := fmt.Sprintf("%s:%d", serveHost, servePort)
// serviceManager := getServiceManager() shares miner lifecycle state across `mining start`, `mining stop`, and `mining serve`.
@ -64,8 +64,8 @@ var serveCmd = &cobra.Command{
// go func() { fmt.Print(">> ") } // keeps the interactive shell responsive while the API serves requests.
go func() {
fmt.Printf("Mining service started on http://%s:%d\n", displayHostName, servePort)
fmt.Printf("Swagger documentation is available at http://%s:%d%s/index.html\n", displayHostName, servePort, service.SwaggerUIPath)
fmt.Printf("Mining service started on http://%s:%d\n", displayHost, servePort)
fmt.Printf("Swagger documentation is available at http://%s:%d%s/index.html\n", displayHost, servePort, service.SwaggerUIPath)
fmt.Println("Entering interactive shell. Type 'exit' or 'quit' to stop.")
fmt.Print(">> ")
@ -82,14 +82,14 @@ var serveCmd = &cobra.Command{
return
}
tokens := strings.Fields(inputLine)
if len(tokens) == 0 {
inputTokens := strings.Fields(inputLine)
if len(inputTokens) == 0 {
fmt.Print(">> ")
continue
}
shellCommand := strings.ToLower(tokens[0])
commandArgs := tokens[1:]
shellCommand := strings.ToLower(inputTokens[0])
commandArgs := inputTokens[1:]
switch shellCommand {
case "start":

View file

@ -123,34 +123,34 @@ Available presets:
},
}
// getSimulatedConfig returns configuration for a simulated miner based on flags.
// getSimulatedConfig(0) returns a simulated miner such as `sim-cpu-medium-001` with preset-driven hashrate and algorithm defaults.
func getSimulatedConfig(index int) mining.SimulatedMinerConfig {
// name := fmt.Sprintf("sim-cpu-medium-001", index+1) // keeps the simulated miner names predictable.
name := fmt.Sprintf("sim-%s-%03d", simulationPreset, index+1)
var config mining.SimulatedMinerConfig
var simulatedConfig mining.SimulatedMinerConfig
if preset, ok := mining.SimulatedMinerPresets[simulationPreset]; ok {
config = preset
simulatedConfig = preset
} else {
config = mining.SimulatedMinerPresets["cpu-medium"]
simulatedConfig = mining.SimulatedMinerPresets["cpu-medium"]
}
config.Name = name
simulatedConfig.Name = name
// simulationHashrate = 8000 // overrides the preset with a custom 8 kH/s baseline.
if simulationHashrate > 0 {
config.BaseHashrate = simulationHashrate
simulatedConfig.BaseHashrate = simulationHashrate
}
// simulationAlgorithm = "rx/0" // swaps the preset algorithm before the miner starts.
if simulationAlgorithm != "" {
config.Algorithm = simulationAlgorithm
simulatedConfig.Algorithm = simulationAlgorithm
}
variance := 0.1 + rand.Float64()*0.1 // 10-20% variance
config.BaseHashrate = int(float64(config.BaseHashrate) * (0.9 + rand.Float64()*0.2))
config.Variance = variance
simulatedConfig.BaseHashrate = int(float64(simulatedConfig.BaseHashrate) * (0.9 + rand.Float64()*0.2))
simulatedConfig.Variance = variance
return config
return simulatedConfig
}
func init() {