1
0
Fork 0
forked from lthn/blockchain

added rpc command for ignoring offline status(for debug)

This commit is contained in:
crypro.zoidberg 2019-04-14 14:15:24 +02:00
parent 6976ebb18d
commit e0e4220e79
5 changed files with 14 additions and 4 deletions

View file

@ -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<int>(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;

View file

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

View file

@ -24,23 +24,29 @@ namespace currency
{
const command_line::arg_descriptor<std::string> arg_rpc_bind_ip = {"rpc-bind-ip", "", "127.0.0.1"};
const command_line::arg_descriptor<std::string> arg_rpc_bind_port = {"rpc-bind-port", "", std::to_string(RPC_DEFAULT_PORT)};
const command_line::arg_descriptor<bool> 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<currency::t_currency_protocol_handler<currency::core> >& 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");

View file

@ -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<std::string, currency::block> m_session_jobs; //session id -> blob

View file

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