From 081fc03aaed7a4ddcd51897fbad1ad8dbc5247b2 Mon Sep 17 00:00:00 2001 From: Matt Hess Date: Thu, 13 Nov 2025 16:56:59 +0000 Subject: [PATCH] Add status display and runtime command for donate-time - status command now shows current donation time setting - donate_time command allows runtime adjustment (1-50 minutes) - Changes take effect immediately without resetting cycle timer --- src/console_commands.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/console_commands.cpp b/src/console_commands.cpp index 7445a09..db5ebb2 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -165,7 +165,7 @@ typedef struct cmd { cmdfunc *func; } cmd; -static cmdfunc do_help, do_status, do_loglevel, do_addpeers, do_droppeers, do_showpeers, do_showworkers, do_showbans, do_showhosts, do_nexthost, do_outpeers, do_inpeers, do_exit, do_version; +static cmdfunc do_help, do_status, do_loglevel, do_addpeers, do_droppeers, do_showpeers, do_showworkers, do_showbans, do_showhosts, do_nexthost, do_outpeers, do_inpeers, do_donatetime, do_exit, do_version; #ifdef WITH_RANDOMX static cmdfunc do_start_mining, do_stop_mining; @@ -188,6 +188,7 @@ static cmd cmds[] = { { STRCONST("start_mining"), "", "start mining", do_start_mining }, { STRCONST("stop_mining"), "", "stop mining", do_stop_mining }, #endif + { STRCONST("donate_time"), "", "set donation time (1-50 minutes per 100)", do_donatetime }, { STRCONST("exit"), "", "terminate p2pool", do_exit }, { STRCONST("version"), "", "show p2pool version", do_version }, { STRCNULL, NULL, NULL, NULL } @@ -228,6 +229,8 @@ static void do_status(p2pool *m_pool, const char * /* args */) indexed_hash::print_status(); #endif + LOGINFO(0, "Dev donation: " << log::LightCyan() << m_pool->params().m_donateLevel << log::NoColor() << " minute(s) per 100 minute cycle"); + bkg_jobs_tracker->print_status(); if (p2p) { @@ -376,6 +379,20 @@ static void do_inpeers(p2pool* m_pool, const char* args) } } +static void do_donatetime(p2pool* m_pool, const char* args) +{ + uint32_t minutes = strtoul(args, nullptr, 10); + if (minutes < 1 || minutes > 50) { + LOGERR(0, "Invalid donation time " << minutes << ", must be 1-50"); + return; + } + + // Cast away const - params are mutable at runtime for console commands + const_cast(m_pool->params()).m_donateLevel = minutes; + + LOGINFO(0, log::LightCyan() << "Dev donation time updated to " << log::LightGreen() << minutes << log::LightCyan() << " minute(s) per 100 minute cycle"); +} + #ifdef WITH_RANDOMX static void do_start_mining(p2pool* m_pool, const char* args) {