From cd2f044ad888801f95dd8e20177c42ec4e8c3e95 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 25 Dec 2024 02:22:22 +0100 Subject: [PATCH] an attempt to calm down heuristic av by disabling cpu mining in mainnet build --- src/currency_core/blockchain_storage.cpp | 1 - src/currency_core/miner.cpp | 61 +++++++++++++++++++++++- src/currency_core/miner.h | 7 ++- src/currency_core/miner_common.h | 8 ---- src/daemon/daemon_commands_handler.h | 51 +++++++++++--------- 5 files changed, 93 insertions(+), 35 deletions(-) delete mode 100644 src/currency_core/miner_common.h diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 2a6af842..ab6b33b8 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -30,7 +30,6 @@ #include "common/boost_serialization_helper.h" #include "warnings.h" #include "crypto/hash.h" -#include "miner_common.h" #include "storages/portable_storage_template_helper.h" #include "basic_pow_helpers.h" #include "version.h" diff --git a/src/currency_core/miner.cpp b/src/currency_core/miner.cpp index 109d9966..472c4654 100644 --- a/src/currency_core/miner.cpp +++ b/src/currency_core/miner.cpp @@ -31,6 +31,62 @@ using namespace epee; namespace currency { +#ifndef CPU_MINING_ENABLED + + // miner stub + + miner::miner(i_miner_handler* phandler, blockchain_storage& bc) + {} + miner::~miner() + {} + bool miner::init(const boost::program_options::variables_map& vm) + { + return false; + } + bool miner::deinit() + { + return false; + } + void miner::init_options(boost::program_options::options_description& desc) + {} + bool miner::start(const account_public_address& adr, size_t threads_count) + { + return false; + } + bool miner::stop() + { + return false; + } + bool miner::is_mining() + { + return false; + } + void miner::do_print_hashrate(bool do_hr) + {} + void miner::pause() + {} + void miner::resume() + {} + bool miner::on_block_chain_update() + { + return false; + } + uint64_t miner::get_speed() + { + return 0; + } + void miner::on_synchronized() + {} + bool miner::on_idle() + { + return false; + } + + + +#else + + namespace { const command_line::arg_descriptor arg_extra_messages ("extra-messages-file", "Specify file for extra messages to include into coinbase transactions"); @@ -379,5 +435,8 @@ namespace currency return true; } //----------------------------------------------------------------------------------------------------- -} + +#endif // #ifndef CPU_MINING_ENABLED + +} // namespace currency diff --git a/src/currency_core/miner.h b/src/currency_core/miner.h index c8a37225..6b3886d1 100644 --- a/src/currency_core/miner.h +++ b/src/currency_core/miner.h @@ -7,6 +7,11 @@ #pragma once +#ifdef TESTNET +#define CPU_MINING_ENABLED // disable CPU mining capabilities in mainnet +#endif // #ifndef TESTNET + + #include #include #include @@ -124,5 +129,3 @@ namespace currency }; } - - diff --git a/src/currency_core/miner_common.h b/src/currency_core/miner_common.h deleted file mode 100644 index 9c6db391..00000000 --- a/src/currency_core/miner_common.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2014-2018 Zano Project -// Copyright (c) 2014-2018 The Louisdor Project -// Copyright (c) 2012-2013 The Boolberry developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#pragma once - diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 1b26fb73..2920c118 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Zano Project +// Copyright (c) 2014-2024 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying @@ -49,12 +49,14 @@ public: m_cmd_binder.set_handler("print_tx", boost::bind(&daemon_commands_handler::print_tx, this, ph::_1), "Print transaction, print_tx "); m_cmd_binder.set_handler("print_asset_info", boost::bind(&daemon_commands_handler::print_asset_info, this, ph::_1), "Print information about the given asset by its id"); m_cmd_binder.set_handler("print_blocked_ips", boost::bind(&daemon_commands_handler::print_blocked_ips, this, ph::_1), "Print ip address blacklists"); +#ifdef CPU_MINING_ENABLED m_cmd_binder.set_handler("start_mining", boost::bind(&daemon_commands_handler::start_mining, this, ph::_1), "Start mining for specified address, start_mining [threads=1]"); m_cmd_binder.set_handler("stop_mining", boost::bind(&daemon_commands_handler::stop_mining, this, ph::_1), "Stop mining"); - m_cmd_binder.set_handler("print_pool", boost::bind(&daemon_commands_handler::print_pool, this, ph::_1), "Print transaction pool (long format)"); - m_cmd_binder.set_handler("print_pool_sh", boost::bind(&daemon_commands_handler::print_pool_sh, this, ph::_1), "Print transaction pool (short format)"); m_cmd_binder.set_handler("show_hr", boost::bind(&daemon_commands_handler::show_hr, this, ph::_1), "Start showing hash rate"); m_cmd_binder.set_handler("hide_hr", boost::bind(&daemon_commands_handler::hide_hr, this, ph::_1), "Stop showing hash rate"); +#endif + m_cmd_binder.set_handler("print_pool", boost::bind(&daemon_commands_handler::print_pool, this, ph::_1), "Print transaction pool (long format)"); + m_cmd_binder.set_handler("print_pool_sh", boost::bind(&daemon_commands_handler::print_pool_sh, this, ph::_1), "Print transaction pool (short format)"); m_cmd_binder.set_handler("save", boost::bind(&daemon_commands_handler::save, this, ph::_1), "Save blockchain"); m_cmd_binder.set_handler("print_daemon_stat", boost::bind(&daemon_commands_handler::print_daemon_stat, this, ph::_1), "Print daemon stat"); m_cmd_binder.set_handler("print_debug_stat", boost::bind(&daemon_commands_handler::print_debug_stat, this, ph::_1), "Print debug stat info"); @@ -184,25 +186,6 @@ private: return true; } - //-------------------------------------------------------------------------------- - bool show_hr(const std::vector& args) - { - if (!m_srv.get_payload_object().get_core().get_miner().is_mining()) - { - std::cout << "Mining is not started. You need start mining before you can see hash rate." << ENDL; - } - else - { - m_srv.get_payload_object().get_core().get_miner().do_print_hashrate(true); - } - return true; - } - //-------------------------------------------------------------------------------- - bool hide_hr(const std::vector& args) - { - m_srv.get_payload_object().get_core().get_miner().do_print_hashrate(false); - return true; - } //-------------------------------------------------------------------------------- bool print_bc_outs(const std::vector& args) { @@ -910,7 +893,9 @@ private: { LOG_PRINT_L0("Pool state: " << ENDL << m_srv.get_payload_object().get_core().print_pool(true)); return true; - } //-------------------------------------------------------------------------------- + } + //-------------------------------------------------------------------------------- +#ifdef CPU_MINING_ENABLED bool start_mining(const std::vector& args) { if (!args.size()) @@ -941,6 +926,26 @@ private: m_srv.get_payload_object().get_core().get_miner().stop(); return true; } + //-------------------------------------------------------------------------------- + bool show_hr(const std::vector& args) + { + if (!m_srv.get_payload_object().get_core().get_miner().is_mining()) + { + std::cout << "Mining is not started. You need start mining before you can see hash rate." << ENDL; + } + else + { + m_srv.get_payload_object().get_core().get_miner().do_print_hashrate(true); + } + return true; + } + //-------------------------------------------------------------------------------- + bool hide_hr(const std::vector& args) + { + m_srv.get_payload_object().get_core().get_miner().do_print_hashrate(false); + return true; + } +#endif // #ifdef CPU_MINING_ENABLED //-------------------------------------------------------------------------------- bool forecast_difficulty(const std::vector& args) {