diff --git a/nano/nano_node/entry.cpp b/nano/nano_node/entry.cpp index 8c5dab06..0ec6c703 100644 --- a/nano/nano_node/entry.cpp +++ b/nano/nano_node/entry.cpp @@ -2,7 +2,9 @@ #include #include #include +#include #include +#include #include @@ -41,6 +43,7 @@ int main (int argc, char * const * argv) ("debug_profile_sign", "Profile signature generation") ("debug_profile_process", "Profile active blocks processing (only for nano_test_network)") ("debug_profile_votes", "Profile votes processing (only for nano_test_network)") + ("debug_rpc", "Read an RPC command from stdin and invoke it. Network operations will have no effect.") ("debug_validate_blocks", "Check all blocks for correct hash, signature, work value") ("platform", boost::program_options::value (), "Defines the for OpenCL commands") ("device", boost::program_options::value (), "Defines for OpenCL command") @@ -609,6 +612,29 @@ int main (int argc, char * const * argv) std::cerr << "For this test ACTIVE_NETWORK should be nano_test_network" << std::endl; } } + else if (vm.count ("debug_rpc")) + { + std::string rpc_input_l; + std::ostringstream command_l; + while (std::cin >> rpc_input_l) + { + command_l << rpc_input_l; + } + + auto response_handler_l ([](boost::property_tree::ptree const & tree_a) { + boost::property_tree::write_json (std::cout, tree_a); + // Terminate as soon as we have the result, even if background threads (like work generation) are running. + std::exit (0); + }); + + nano::inactive_node inactive_node_l (data_path); + nano::rpc_config rpc_config_l; + rpc_config_l.enable_control = true; + std::unique_ptr rpc_l = get_rpc (inactive_node_l.node->io_ctx, *inactive_node_l.node, rpc_config_l); + std::string req_id_l ("1"); + nano::rpc_handler handler_l (*inactive_node_l.node, *rpc_l, command_l.str (), req_id_l, response_handler_l); + handler_l.process_request (); + } else if (vm.count ("debug_validate_blocks")) { nano::inactive_node node (data_path);