an attempt to calm down heuristic av by disabling cpu mining in mainnet build

This commit is contained in:
sowle 2024-12-25 02:22:22 +01:00
parent 484f362676
commit cd2f044ad8
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
5 changed files with 93 additions and 35 deletions

View file

@ -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"

View file

@ -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<std::string> 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

View file

@ -7,6 +7,11 @@
#pragma once
#ifdef TESTNET
#define CPU_MINING_ENABLED // disable CPU mining capabilities in mainnet
#endif // #ifndef TESTNET
#include <boost/atomic.hpp>
#include <boost/program_options.hpp>
#include <atomic>
@ -124,5 +129,3 @@ namespace currency
};
}

View file

@ -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

View file

@ -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 <transaction_hash>");
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 <addr> [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<std::string>& 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<std::string>& args)
{
m_srv.get_payload_object().get_core().get_miner().do_print_hashrate(false);
return true;
}
//--------------------------------------------------------------------------------
bool print_bc_outs(const std::vector<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& args)
{