feat(mining): host a RandomX stratum pool from the node (v1.3.0+)
Add an opt-in "Host a mining pool (stratum)" toggle so a v1.3.0+ node can run its native RandomX stratum server for other miners to point at. Settings toggle + optional allow-IP/CIDR; passes -stratum (+ -stratumallowip) to the daemon launch args, mirroring the -maxconnections plumbing (EmbeddedDaemon::setStratumHosting <- DaemonController::syncSettings <- Settings). Backwards compatible / safe by default: - UI gated on daemon_version >= 1030000, so it's never offered where it would do nothing. - The launch flag is harmless on older daemons (they ignore unknown args), and the toggle can only be enabled while connected to a v1.3.0+ node anyway. - Blank allow-IP => the daemon serves loopback only (its safe default); entering a subnet opens it to that LAN, with an explicit exposure warning in the UI. - Takes effect on the next daemon start/restart. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,6 +116,8 @@ struct SettingsPageState {
|
||||
LowSpecSnapshot low_spec_snapshot;
|
||||
bool keep_daemon_running = false;
|
||||
bool stop_external_daemon = false;
|
||||
bool stratum_host = false; // O2: host a RandomX stratum pool from the node (v1.3.0+)
|
||||
char stratum_allowip[64] = ""; // -stratumallowip subnet (blank = loopback only)
|
||||
bool lite_lifecycle_expanded = false;
|
||||
int lite_lifecycle_operation = 0;
|
||||
char lite_wallet_path[256] = "";
|
||||
@@ -420,6 +422,9 @@ static void loadSettingsPageState(config::Settings* settings) {
|
||||
Layout::setUserFontScale(s_settingsState.font_scale); // sync with Layout on load
|
||||
s_settingsState.keep_daemon_running = settings->getKeepDaemonRunning();
|
||||
s_settingsState.stop_external_daemon = settings->getStopExternalDaemon();
|
||||
s_settingsState.stratum_host = settings->getStratumHost();
|
||||
std::snprintf(s_settingsState.stratum_allowip, sizeof(s_settingsState.stratum_allowip), "%s",
|
||||
settings->getStratumAllowIp().c_str());
|
||||
// Lite-server selection is managed entirely by the Network tab (not the Settings page).
|
||||
s_settingsState.mine_when_idle = settings->getMineWhenIdle();
|
||||
s_settingsState.mine_idle_delay = settings->getMineIdleDelay();
|
||||
@@ -483,6 +488,8 @@ static void saveSettingsPageState(config::Settings* settings) {
|
||||
settings->setFontScale(s_settingsState.font_scale);
|
||||
settings->setKeepDaemonRunning(s_settingsState.keep_daemon_running);
|
||||
settings->setStopExternalDaemon(s_settingsState.stop_external_daemon);
|
||||
settings->setStratumHost(s_settingsState.stratum_host);
|
||||
settings->setStratumAllowIp(s_settingsState.stratum_allowip);
|
||||
// Lite-server selection is owned by the Network tab; the Settings page no longer writes it.
|
||||
settings->setMineWhenIdle(s_settingsState.mine_when_idle);
|
||||
settings->setMineIdleDelay(s_settingsState.mine_idle_delay);
|
||||
@@ -1207,6 +1214,26 @@ void RenderSettingsPage(App* app) {
|
||||
if (CB(TrId("stop_external", "stop_ext"), &s_settingsState.stop_external_daemon))
|
||||
saveSettingsPageState(app->settings());
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_stop_external"));
|
||||
|
||||
// O2: host a RandomX stratum pool from this node. Only offered on daemons that implement
|
||||
// it (v1.3.0+, version encoded major*1e6+minor*1e4+rev*100+build), so we never show a
|
||||
// toggle that does nothing. Takes effect on the next daemon start/restart. Blank allow-IP
|
||||
// = loopback only (safe); a subnet opens it to that LAN.
|
||||
if (app->state().daemon_version >= 1030000) {
|
||||
if (CB(TrId("stratum_host", "strat_host"), &s_settingsState.stratum_host))
|
||||
saveSettingsPageState(app->settings());
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_stratum_host"));
|
||||
if (s_settingsState.stratum_host) {
|
||||
ImGui::TextDisabled(" %s", TR("stratum_host_hint"));
|
||||
ImGui::SetNextItemWidth(220.0f * Layout::dpiScale());
|
||||
if (ImGui::InputTextWithHint("##stratumallowip", TR("stratum_allowip_hint"),
|
||||
s_settingsState.stratum_allowip, sizeof(s_settingsState.stratum_allowip)))
|
||||
saveSettingsPageState(app->settings());
|
||||
if (s_settingsState.stratum_allowip[0] != '\0')
|
||||
ImGui::TextColored(ImVec4(0.95f, 0.75f, 0.25f, 1.0f), " %s",
|
||||
TR("stratum_expose_warn"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CB(TrId("verbose_logging", "verbose"), &s_settingsState.verbose_logging)) {
|
||||
dragonx::util::Logger::instance().setVerbose(s_settingsState.verbose_logging);
|
||||
|
||||
Reference in New Issue
Block a user