parent
823e2d78e4
commit
28ebc92229
3 changed files with 14 additions and 10 deletions
|
@ -169,11 +169,12 @@ void rai::rpc::stop ()
|
|||
acceptor.close ();
|
||||
}
|
||||
|
||||
rai::rpc_handler::rpc_handler (rai::node & node_a, rai::rpc & rpc_a, std::string const & body_a, std::function<void(boost::property_tree::ptree const &)> const & response_a) :
|
||||
rai::rpc_handler::rpc_handler (rai::node & node_a, rai::rpc & rpc_a, std::string const & body_a, std::string const & request_id_a, std::function<void(boost::property_tree::ptree const &)> const & response_a) :
|
||||
body (body_a),
|
||||
node (node_a),
|
||||
rpc (rpc_a),
|
||||
response (response_a)
|
||||
response (response_a),
|
||||
request_id (request_id_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4537,7 +4538,8 @@ void rai::rpc_connection::read ()
|
|||
this_l->node->background ([this_l]() {
|
||||
auto start (std::chrono::steady_clock::now ());
|
||||
auto version (this_l->request.version ());
|
||||
auto response_handler ([this_l, version, start](boost::property_tree::ptree const & tree_a) {
|
||||
std::string request_id (boost::str (boost::format ("%1%") % boost::io::group (std::hex, std::showbase, reinterpret_cast<uintptr_t> (this_l.get ()))));
|
||||
auto response_handler ([this_l, version, start, request_id](boost::property_tree::ptree const & tree_a) {
|
||||
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, tree_a);
|
||||
|
@ -4549,12 +4551,12 @@ void rai::rpc_connection::read ()
|
|||
|
||||
if (this_l->node->config.logging.log_rpc ())
|
||||
{
|
||||
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast<std::chrono::microseconds> (std::chrono::steady_clock::now () - start).count () % boost::io::group (std::hex, std::showbase, reinterpret_cast<uintptr_t> (this_l.get ())));
|
||||
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast<std::chrono::microseconds> (std::chrono::steady_clock::now () - start).count () % request_id);
|
||||
}
|
||||
});
|
||||
if (this_l->request.method () == boost::beast::http::verb::post)
|
||||
{
|
||||
auto handler (std::make_shared<rai::rpc_handler> (*this_l->node, this_l->rpc, this_l->request.body (), response_handler));
|
||||
auto handler (std::make_shared<rai::rpc_handler> (*this_l->node, this_l->rpc, this_l->request.body (), request_id, response_handler));
|
||||
handler->process_request ();
|
||||
}
|
||||
else
|
||||
|
@ -4607,7 +4609,7 @@ void rai::rpc_handler::process_request ()
|
|||
}
|
||||
if (node.config.logging.log_rpc ())
|
||||
{
|
||||
BOOST_LOG (node.log) << body;
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("%1% ") % request_id) << body;
|
||||
}
|
||||
if (action == "account_balance")
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
class rpc_handler : public std::enable_shared_from_this<rai::rpc_handler>
|
||||
{
|
||||
public:
|
||||
rpc_handler (rai::node &, rai::rpc &, std::string const &, std::function<void(boost::property_tree::ptree const &)> const &);
|
||||
rpc_handler (rai::node &, rai::rpc &, std::string const &, std::string const &, std::function<void(boost::property_tree::ptree const &)> const &);
|
||||
void process_request ();
|
||||
void account_balance ();
|
||||
void account_block_count ();
|
||||
|
@ -217,6 +217,7 @@ public:
|
|||
void work_peers ();
|
||||
void work_peers_clear ();
|
||||
std::string body;
|
||||
std::string request_id;
|
||||
rai::node & node;
|
||||
rai::rpc & rpc;
|
||||
boost::property_tree::ptree request;
|
||||
|
|
|
@ -152,7 +152,8 @@ void rai::rpc_connection_secure::read ()
|
|||
this_l->node->background ([this_l]() {
|
||||
auto start (std::chrono::steady_clock::now ());
|
||||
auto version (this_l->request.version ());
|
||||
auto response_handler ([this_l, version, start](boost::property_tree::ptree const & tree_a) {
|
||||
std::string request_id (boost::str (boost::format ("%1%") % boost::io::group (std::hex, std::showbase, reinterpret_cast<uintptr_t> (this_l.get ()))));
|
||||
auto response_handler ([this_l, version, start, request_id](boost::property_tree::ptree const & tree_a) {
|
||||
std::stringstream ostream;
|
||||
boost::property_tree::write_json (ostream, tree_a);
|
||||
ostream.flush ();
|
||||
|
@ -171,13 +172,13 @@ void rai::rpc_connection_secure::read ()
|
|||
|
||||
if (this_l->node->config.logging.log_rpc ())
|
||||
{
|
||||
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("TLS: RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast<std::chrono::microseconds> (std::chrono::steady_clock::now () - start).count () % boost::io::group (std::hex, std::showbase, reinterpret_cast<uintptr_t> (this_l.get ())));
|
||||
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("TLS: RPC request %2% completed in: %1% microseconds") % std::chrono::duration_cast<std::chrono::microseconds> (std::chrono::steady_clock::now () - start).count () % request_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (this_l->request.method () == boost::beast::http::verb::post)
|
||||
{
|
||||
auto handler (std::make_shared<rai::rpc_handler> (*this_l->node, this_l->rpc, this_l->request.body (), response_handler));
|
||||
auto handler (std::make_shared<rai::rpc_handler> (*this_l->node, this_l->rpc, this_l->request.body (), request_id, response_handler));
|
||||
handler->process_request ();
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue