forked from lthn/blockchain
Merge remote-tracking branch 'origin/nocpumining' into develop
This commit is contained in:
commit
e73eb4f59a
9 changed files with 110 additions and 39 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,63 @@ using namespace epee;
|
|||
namespace currency
|
||||
{
|
||||
|
||||
#ifndef CPU_MINING_ENABLED
|
||||
|
||||
// CPU mining disabled
|
||||
// currency::miner stub implementation
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// end of currency::miner stub implementation
|
||||
|
||||
#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 +436,8 @@ namespace currency
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
#endif // #ifndef CPU_MINING_ENABLED
|
||||
|
||||
} // namespace currency
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2022 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
|
||||
|
|
@ -925,6 +925,7 @@ namespace currency
|
|||
return call_res;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
bool core_rpc_server::on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res, connection_context& cntx)
|
||||
{
|
||||
CHECK_CORE_READY();
|
||||
|
|
@ -955,6 +956,7 @@ namespace currency
|
|||
res.status = API_RETURN_CODE_OK;
|
||||
return true;
|
||||
}
|
||||
#endif // #ifdef CPU_MINING_ENABLED
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res, connection_context& cntx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ namespace currency
|
|||
bool on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res, connection_context& cntx);
|
||||
bool on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res, connection_context& cntx);
|
||||
bool on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res, connection_context& cntx);
|
||||
bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res, connection_context& cntx);
|
||||
bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res, connection_context& cntx);
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res, connection_context& cntx);
|
||||
bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res, connection_context& cntx);
|
||||
#endif
|
||||
bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_LEGACY::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS_LEGACY::response& res, connection_context& cntx);
|
||||
bool on_get_random_outs1(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res, connection_context& cntx);
|
||||
bool on_get_random_outs3(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS3::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS3::response& res, connection_context& cntx);
|
||||
|
|
@ -56,7 +58,7 @@ namespace currency
|
|||
bool on_get_tx_pool(const COMMAND_RPC_GET_TX_POOL::request& req, COMMAND_RPC_GET_TX_POOL::response& res, connection_context& cntx);
|
||||
bool on_check_keyimages(const COMMAND_RPC_CHECK_KEYIMAGES::request& req, COMMAND_RPC_CHECK_KEYIMAGES::response& res, connection_context& cntx);
|
||||
bool on_rpc_get_blocks_details(const COMMAND_RPC_GET_BLOCKS_DETAILS::request& req, COMMAND_RPC_GET_BLOCKS_DETAILS::response& res, connection_context& cntx);
|
||||
bool on_force_relaey_raw_txs(const COMMAND_RPC_FORCE_RELAY_RAW_TXS::request& req, COMMAND_RPC_FORCE_RELAY_RAW_TXS::response& res, connection_context& cntx);
|
||||
bool on_force_relaey_raw_txs(const COMMAND_RPC_FORCE_RELAY_RAW_TXS::request& req, COMMAND_RPC_FORCE_RELAY_RAW_TXS::response& res, connection_context& cntx);
|
||||
bool on_get_offers_ex(const COMMAND_RPC_GET_OFFERS_EX::request& req, COMMAND_RPC_GET_OFFERS_EX::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
|
||||
|
||||
|
|
@ -107,9 +109,11 @@ namespace currency
|
|||
MAP_URI_AUTO_JON2("/getheight", on_get_height, COMMAND_RPC_GET_HEIGHT)
|
||||
MAP_URI_AUTO_JON2("/gettransactions", on_get_transactions, COMMAND_RPC_GET_TRANSACTIONS)
|
||||
MAP_URI_AUTO_JON2("/sendrawtransaction", on_send_raw_tx, COMMAND_RPC_SEND_RAW_TX)
|
||||
MAP_URI_AUTO_JON2("/force_relay", on_force_relaey_raw_txs, COMMAND_RPC_FORCE_RELAY_RAW_TXS)
|
||||
MAP_URI_AUTO_JON2("/force_relay", on_force_relaey_raw_txs, COMMAND_RPC_FORCE_RELAY_RAW_TXS)
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
MAP_URI_AUTO_JON2("/start_mining", on_start_mining, COMMAND_RPC_START_MINING)
|
||||
MAP_URI_AUTO_JON2("/stop_mining", on_stop_mining, COMMAND_RPC_STOP_MINING)
|
||||
#endif
|
||||
MAP_URI_AUTO_JON2("/getinfo", on_get_info, COMMAND_RPC_GET_INFO)
|
||||
// binary RPCs
|
||||
MAP_URI_AUTO_BIN2("/getblocks.bin", on_get_blocks, COMMAND_RPC_GET_BLOCKS_FAST)
|
||||
|
|
|
|||
|
|
@ -288,8 +288,10 @@ simple_wallet::simple_wallet()
|
|||
m_refresh_progress_reporter(*this),
|
||||
m_offline_mode(false)
|
||||
{
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
m_cmd_binder.set_handler("start_mining", boost::bind(&simple_wallet::start_mining, this, ph::_1), "start_mining <threads_count> - Start mining in daemon");
|
||||
m_cmd_binder.set_handler("stop_mining", boost::bind(&simple_wallet::stop_mining, this, ph::_1), "Stop mining in daemon");
|
||||
#endif // #ifdef CPU_MINING_ENABLED
|
||||
m_cmd_binder.set_handler("refresh", boost::bind(&simple_wallet::refresh, this, ph::_1), "Resynchronize transactions and balance");
|
||||
m_cmd_binder.set_handler("balance", boost::bind(&simple_wallet::show_balance, this, ph::_1), "[raw] Show current wallet balance, with 'raw' param it displays all assets without filtering against whitelists");
|
||||
m_cmd_binder.set_handler("show_staking_history", boost::bind(&simple_wallet::show_staking_history, this, ph::_1), "show_staking_history [2] - Show staking transfers, if option provided - number of days for history to display");
|
||||
|
|
@ -761,6 +763,7 @@ bool simple_wallet::save(const std::vector<std::string> &args)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
bool simple_wallet::start_mining(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!try_connect_to_daemon())
|
||||
|
|
@ -815,6 +818,7 @@ bool simple_wallet::stop_mining(const std::vector<std::string>& args)
|
|||
fail_msg_writer() << "mining has NOT been stopped: " << err;
|
||||
return true;
|
||||
}
|
||||
#endif // #ifdef CPU_MINING_ENABLED
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::on_new_block(uint64_t height, const currency::block& block)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,8 +50,10 @@ namespace currency
|
|||
bool close_wallet();
|
||||
|
||||
bool help(const std::vector<std::string> &args = std::vector<std::string>());
|
||||
#ifdef CPU_MINING_ENABLED
|
||||
bool start_mining(const std::vector<std::string> &args);
|
||||
bool stop_mining(const std::vector<std::string> &args);
|
||||
#endif // #ifdef CPU_MINING_ENABLED
|
||||
bool refresh(const std::vector<std::string> &args);
|
||||
bool show_balance(const std::vector<std::string> &args = std::vector<std::string>());
|
||||
bool list_recent_transfers(const std::vector<std::string>& args);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue