Skip to content

Commit

Permalink
RPC debug command line option (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptocode authored and rkeene committed Jan 23, 2019
1 parent b8b50f7 commit 3e87c6f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <nano/nano_node/daemon.hpp>
#include <nano/node/cli.hpp>
#include <nano/node/node.hpp>
#include <nano/node/rpc.hpp>
#include <nano/node/testing.hpp>
#include <sstream>

#include <argon2.h>

Expand Down Expand Up @@ -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<std::string> (), "Defines the <platform> for OpenCL commands")
("device", boost::program_options::value<std::string> (), "Defines <device> for OpenCL command")
Expand Down Expand Up @@ -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<nano::rpc> 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);
Expand Down

0 comments on commit 3e87c6f

Please sign in to comment.