feat(mining): auto-balance driver, per-pool algo, live miner version
- app: periodic weighted-random auto-balance of the pool while pool-mining (~30-min cadence; restarts the miner only when the pick actually changes), plus snapshot + refresh accessors for the UI. - app_network: resolve the xmrig algo per pool at start (pool.dragonx.cc = rx/dragonx, pool.dragonx.is = rx/hush; custom hosts keep the setting). - xmrig_manager: schema-aware pool-side hashrate readout (fixes a silent 0 for Miningcore pools); expose the running miner's version from its HTTP API and a cached `xmrig --version` detection so the UI can show it before mining. - wallet_state: carry the running miner's version. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
src/app.h
24
src/app.h
@@ -19,6 +19,7 @@
|
||||
#include "services/wallet_security_controller.h"
|
||||
#include "services/wallet_security_workflow.h"
|
||||
#include "util/async_task_manager.h"
|
||||
#include "util/pool_stats_service.h"
|
||||
#include "wallet/wallet_capabilities.h"
|
||||
#include "ui/sidebar.h"
|
||||
#include "ui/windows/console_tab.h"
|
||||
@@ -204,6 +205,17 @@ public:
|
||||
return xmrig_manager_ && xmrig_manager_->isRunning();
|
||||
}
|
||||
|
||||
// Auto-balance: latest per-pool hashrate snapshot (for the mining tab pool list),
|
||||
// and a request to refresh it now (Refresh button / switching into Auto mode).
|
||||
util::PoolStatsService::Snapshot poolStatsSnapshot() const {
|
||||
return pool_stats_service_.snapshot();
|
||||
}
|
||||
void requestPoolBalanceRefresh() { balance_refresh_pending_ = true; }
|
||||
|
||||
// Installed miner version (detected from `xmrig --version`, cached; kicks the one-shot
|
||||
// detection on first call) so the mining tab can show it before mining starts.
|
||||
std::string poolMiningInstalledVersion();
|
||||
|
||||
// Mine-when-idle state query
|
||||
bool isIdleMiningActive() const { return idle_mining_active_; }
|
||||
|
||||
@@ -455,6 +467,11 @@ private:
|
||||
void pruneShieldedHistoryScanProgress();
|
||||
void invalidateShieldedHistoryScanProgress(bool persistCache);
|
||||
|
||||
// Auto-balance pool selection: drive the periodic hashrate refresh and apply a
|
||||
// freshly-completed snapshot (weighted-random pick + optional miner restart).
|
||||
void updatePoolAutoBalance();
|
||||
void applyPoolAutoBalance(const util::PoolStatsService::Snapshot& snap);
|
||||
|
||||
// Subsystems
|
||||
std::unique_ptr<rpc::RPCClient> rpc_;
|
||||
std::unique_ptr<rpc::RPCWorker> worker_;
|
||||
@@ -488,6 +505,13 @@ private:
|
||||
bool lite_startup_lock_checked_ = false;
|
||||
std::unique_ptr<daemon::DaemonController> daemon_controller_;
|
||||
std::unique_ptr<daemon::XmrigManager> xmrig_manager_;
|
||||
// Auto-balance runtime state (pool mining, full-node only). The service fetches
|
||||
// pool hashrates off-thread; the RNG drives the weighted-random pick.
|
||||
util::PoolStatsService pool_stats_service_;
|
||||
std::mt19937 balance_rng_;
|
||||
long long last_balance_eval_ms_ = 0; // steady-clock ms of the last refresh kick
|
||||
bool balance_refresh_pending_ = false; // UI asked for an immediate refresh
|
||||
bool balance_snapshot_seen_ = false; // the current in-flight snapshot was applied
|
||||
util::AsyncTaskManager async_tasks_;
|
||||
bool pending_antivirus_dialog_ = false; // Show Windows Defender help dialog
|
||||
|
||||
|
||||
Reference in New Issue
Block a user