aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/daemon_handler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/daemon_handler.cpp')
-rw-r--r--src/rpc/daemon_handler.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp
index 7292176b4..de0510fec 100644
--- a/src/rpc/daemon_handler.cpp
+++ b/src/rpc/daemon_handler.cpp
@@ -33,6 +33,7 @@
#include <stdexcept>
#include <boost/uuid/nil_generator.hpp>
+#include <boost/utility/string_ref.hpp>
// likely included by daemon_handler.h's includes,
// but including here for clarity
#include "cryptonote_core/cryptonote_core.h"
@@ -48,7 +49,7 @@ namespace rpc
{
namespace
{
- using handler_function = std::string(DaemonHandler& handler, const rapidjson::Value& id, const rapidjson::Value& msg);
+ using handler_function = epee::byte_slice(DaemonHandler& handler, const rapidjson::Value& id, const rapidjson::Value& msg);
struct handler_map
{
const char* method_name;
@@ -66,7 +67,7 @@ namespace rpc
}
template<typename Message>
- std::string handle_message(DaemonHandler& handler, const rapidjson::Value& id, const rapidjson::Value& parameters)
+ epee::byte_slice handle_message(DaemonHandler& handler, const rapidjson::Value& id, const rapidjson::Value& parameters)
{
typename Message::Request request{};
request.fromJson(parameters);
@@ -349,10 +350,10 @@ namespace rpc
res.error_details = "Invalid hex";
return;
}
- handleTxBlob(tx_blob, req.relay, res);
+ handleTxBlob(std::move(tx_blob), req.relay, res);
}
- void DaemonHandler::handleTxBlob(const std::string& tx_blob, bool relay, SendRawTx::Response& res)
+ void DaemonHandler::handleTxBlob(std::string&& tx_blob, bool relay, SendRawTx::Response& res)
{
if (!m_p2p.get_payload_object().is_synchronized())
{
@@ -423,7 +424,7 @@ namespace rpc
return;
}
- if(!tvc.m_should_be_relayed || !relay)
+ if(tvc.m_relay == relay_method::none || !relay)
{
MERROR("[SendRawTx]: tx accepted, but not relayed");
res.error_details = "Not relayed";
@@ -434,8 +435,8 @@ namespace rpc
}
NOTIFY_NEW_TRANSACTIONS::request r;
- r.txs.push_back(tx_blob);
- m_core.get_protocol()->relay_transactions(r, boost::uuids::nil_uuid(), epee::net_utils::zone::invalid);
+ r.txs.push_back(std::move(tx_blob));
+ m_core.get_protocol()->relay_transactions(r, boost::uuids::nil_uuid(), epee::net_utils::zone::invalid, relay_method::local);
//TODO: make sure that tx has reached other nodes here, probably wait to receive reflections from other nodes
res.status = Message::STATUS_OK;
@@ -903,7 +904,7 @@ namespace rpc
return true;
}
- std::string DaemonHandler::handle(const std::string& request)
+ epee::byte_slice DaemonHandler::handle(const std::string& request)
{
MDEBUG("Handling RPC request: " << request);
@@ -916,8 +917,11 @@ namespace rpc
if (matched_handler == std::end(handlers) || matched_handler->method_name != request_type)
return BAD_REQUEST(request_type, req_full.getID());
- std::string response = matched_handler->call(*this, req_full.getID(), req_full.getMessage());
- MDEBUG("Returning RPC response: " << response);
+ epee::byte_slice response = matched_handler->call(*this, req_full.getID(), req_full.getMessage());
+
+ const boost::string_ref response_view{reinterpret_cast<const char*>(response.data()), response.size()};
+ MDEBUG("Returning RPC response: " << response_view);
+
return response;
}
catch (const std::exception& e)