Skip to content

Commit 6f40584

Browse files
committed
Let the dashboard set mining cores and pause or resume mining
The Mining panel gets a cores slider (1 to the logical core count) and a pause or resume button. Applying calls miner_start(n) and saves n to <node-dir>/miner-threads, replaced atomically with its old permissions; while paused the count is only saved. Pause calls miner_stop and writes <node-dir>/mining-paused; resume removes it and starts mining on the saved count. After each change the node is read back with eth_mining and the outcome or error is shown in plain words. The new POST endpoints sit behind the dashboard key and the Origin check, and refuse a core count that is not a whole number in range. The page notes that a node restart resumes mining until the installer reads mining-paused.
1 parent 3581a12 commit 6f40584

8 files changed

Lines changed: 804 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ The page refreshes every 5 seconds without reloading. Each panel says "Node not
3737

3838
The dashboard finds your blocks by reading the chain over IPC and keeps what it found in `<node-dir>/dashboard-index.json` (owner-only), with the last block it read, so after a restart it only reads new blocks. On a long chain the first reading is spread over several refreshes. When the chain is reorganised it drops the blocks the new chain replaced and reads again from there; when the payout address changes it starts over.
3939

40+
### Mining controls
41+
42+
The Mining panel has a cores slider, from 1 to the computer's logical core count, and a pause or resume button.
43+
44+
- **Apply** asks the node to mine on that many cores at once (`miner_start`) and saves the number in `<node-dir>/miner-threads`, the file the installer and updater read, so restarts and updates keep it. The file is replaced in one step (a temporary file renamed over it) and keeps its permissions. While mining is paused the number is only saved, and resuming uses it.
45+
- **Pause** stops mining (`miner_stop`) and writes `<node-dir>/mining-paused`; the node keeps syncing. **Resume** removes that file and starts mining on the saved core count. Until the node installer reads `mining-paused`, a node restart resumes mining.
46+
47+
After each change the dashboard reads the node back (`eth_mining`) and says in plain words what happened, or what went wrong. The controls are `POST /api/mining/cores` (body `{"cores": n}`, a whole number in range, else 400), `POST /api/mining/pause` and `POST /api/mining/resume`, behind the dashboard key and the Origin check.
48+
4049
The estimates use a target block time of 15 seconds. Each panel reads one endpoint, behind the dashboard key: `/api/node`, `/api/mining`, `/api/network`, `/api/rewards` and `/api/log`.
4150

4251
### Access

0 commit comments

Comments
 (0)