Fix MaraFW detection priority + add Pause/Resume support for MaraFW (Kaonsu) and AntMinerV2020 #122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes miner identification when multiple discovery probes succeed (notably MaraFW/Marathon showing a stock-like Web UI), and adds working
pause()/resume()support for:The goal is reliable detection + reliable pause/resume behavior across these firmwares.
Problem
1) MaraFW sometimes detected as Stock
Discovery runs multiple probes in parallel (HTTP, RPC, etc.). Previously, the factory returned the first successful identification result. On MaraFW devices, the HTTP probe can look “stock”, so the code could select the Stock backend before the RPC probe had a chance to report MaraFW.
Result: MaraFW miners were misclassified as Stock, and stock commands were used against a MaraFW device.
2) Marathon backend had no Pause/Resume
MaraV1previously returnedUnsupported commandfor Pause/Resume.3) AntMinerV2020 needed Pause/Resume across firmware variants
Some Bitmain firmwares use
bitmain-work-mode, while older ones useminer-mode.Changes
A) Prefer explicit firmware IDs over Stock during discovery
File:
src/miners/factory/mod.rsWhy: MaraFW/Marathon should win even if the HTTP probe returns a stock-like result first.
B) Implement Pause/Resume for MaraFW (Marathon backend) via Kaonsu Web API
File:
src/miners/backends/marathon/v1/mod.rsAdds helper methods to
MaraV1:get_work_mode()GET /kaonsu/v1/miner_config/mode/work-mode-selectorset_work_mode(mode)GET /kaonsu/v1/miner_config(full config)mode.work-mode-selectorPOST /kaonsu/v1/miner_config{"error":false,"msg":"success"}last_mode_before_sleep_from_history()GET /kaonsu/v1/log?type=miner_config_historyMode/WorkModeSelectortransitions whereto == "Sleep""from"mode (Auto / Fixed / Stock)Behavior
pause()Sleep, returnstrue(no-op)Sleepresume()Sleep, returnstrue(no-op)Sleep, restores the last mode before Sleep using historyStockif history has no matchWhy history-based resume: it restores the correct mode even if Sleep was triggered via the GUI or another tool.
C) Implement Pause/Resume for AntMinerV2020 (stock)
File:
src/miners/backends/antminer/v2020/mod.rsReads current config via
get_miner_conf()If
bitmain-work-modeexists:"1""0"Otherwise fallback:
"miner-mode": "Sleep""miner-mode": "Normal"Testing / Verification
cargo build(local)Manual MaraFW verification:
POST /kaonsu/v1/miner_configreturns{"error":false,"msg":"success"}GET /kaonsu/v1/miner_configminer_config_historyNotes
miner_config+ config history log).