From e0e4220e79adcbb73f9b727cfb9e6ce6975910c2 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Sun, 14 Apr 2019 14:15:24 +0200 Subject: [PATCH] added rpc command for ignoring offline status(for debug) --- src/currency_core/basic_pow_helpers.cpp | 4 ++-- src/currency_core/basic_pow_helpers.h | 2 +- src/rpc/core_rpc_server.cpp | 10 +++++++++- src/rpc/core_rpc_server.h | 1 + src/wallet/wallet_rpc_server.cpp | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/currency_core/basic_pow_helpers.cpp b/src/currency_core/basic_pow_helpers.cpp index 94af36d9..0509ff65 100644 --- a/src/currency_core/basic_pow_helpers.cpp +++ b/src/currency_core/basic_pow_helpers.cpp @@ -47,11 +47,11 @@ namespace currency return result; } //-------------------------------------------------------------- - crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_long_ash, uint64_t nonce) + crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_header_hash, uint64_t nonce) { int epoch = ethash_height_to_epoch(height); const auto& context = progpow::get_global_epoch_context_full(static_cast(epoch)); - auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_long_ash, nonce); + auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_header_hash, nonce); crypto::hash result = currency::null_hash; memcpy(&result.data, &res_eth.final_hash, sizeof(res_eth.final_hash)); return result; diff --git a/src/currency_core/basic_pow_helpers.h b/src/currency_core/basic_pow_helpers.h index 4bea2718..36b2f0ad 100644 --- a/src/currency_core/basic_pow_helpers.h +++ b/src/currency_core/basic_pow_helpers.h @@ -29,7 +29,7 @@ namespace currency { int ethash_height_to_epoch(uint64_t height); crypto::hash ethash_epoch_to_seed(int epoch); - crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_long_ash, uint64_t nonce); + crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_header_hash, uint64_t nonce); void get_block_longhash(const block& b, crypto::hash& res); crypto::hash get_block_longhash(const block& b); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index a27ec33d..64a38cc2 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -24,23 +24,29 @@ namespace currency { const command_line::arg_descriptor arg_rpc_bind_ip = {"rpc-bind-ip", "", "127.0.0.1"}; const command_line::arg_descriptor arg_rpc_bind_port = {"rpc-bind-port", "", std::to_string(RPC_DEFAULT_PORT)}; + const command_line::arg_descriptor arg_rpc_ignore_status = {"rpc-ignore-offline", "Let rpc calls despite online/offline status", false, true }; } //----------------------------------------------------------------------------------- void core_rpc_server::init_options(boost::program_options::options_description& desc) { command_line::add_arg(desc, arg_rpc_bind_ip); command_line::add_arg(desc, arg_rpc_bind_port); + command_line::add_arg(desc, arg_rpc_ignore_status); } //------------------------------------------------------------------------------------------------------------------------------ core_rpc_server::core_rpc_server(core& cr, nodetool::node_server >& p2p, bc_services::bc_offers_service& of - ) :m_core(cr), m_p2p(p2p), m_of(of), m_session_counter(0) + ) :m_core(cr), m_p2p(p2p), m_of(of), m_session_counter(0), m_ignore_status(false) {} //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::handle_command_line(const boost::program_options::variables_map& vm) { m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip); m_port = command_line::get_arg(vm, arg_rpc_bind_port); + if (command_line::has_arg(vm, arg_rpc_ignore_status)) + { + m_ignore_status = command_line::get_arg(vm, arg_rpc_ignore_status); + } return true; } //------------------------------------------------------------------------------------------------------------------------------ @@ -55,6 +61,8 @@ namespace currency bool core_rpc_server::check_core_ready_(const std::string& calling_method) { #ifndef TESTNET + if (m_ignore_status) + return true; if(!m_p2p.get_payload_object().is_synchronized()) { LOG_PRINT_L0("[" << calling_method << "]Core busy cz is_synchronized"); diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 53e723c7..c74e31b4 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -177,6 +177,7 @@ namespace currency bc_services::bc_offers_service& m_of; std::string m_port; std::string m_bind_ip; + bool m_ignore_status; //mining stuff epee::critical_section m_session_jobs_lock; std::map m_session_jobs; //session id -> blob diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 5d7846b2..53af9d91 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -28,6 +28,7 @@ namespace tools command_line::add_arg(desc, arg_rpc_bind_ip); command_line::add_arg(desc, arg_rpc_bind_port); command_line::add_arg(desc, arg_miner_text_info); + command_line::add_arg(desc, arg_rpc_ignore_status); } //------------------------------------------------------------------------------------------------------------------------------ wallet_rpc_server::wallet_rpc_server(wallet2& w):m_wallet(w), m_do_mint(false)