diff options
author | Lee Clagett <code@leeclagett.com> | 2019-11-17 06:06:10 +0000 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-04-03 01:56:17 +0000 |
commit | da9915746219482c25b96406d475c6fde9b02a31 (patch) | |
tree | 5b1c6be33c9511dc6af48b63d5f87877b9bd06ae /src/rpc/zmq_server.cpp | |
parent | Merge pull request #6470 (diff) | |
download | monero-da9915746219482c25b96406d475c6fde9b02a31.tar.xz |
Use byte_slice for sending zmq messages - removes data copy within zmq
Diffstat (limited to 'src/rpc/zmq_server.cpp')
-rw-r--r-- | src/rpc/zmq_server.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp index 1ee55673e..91e4751d1 100644 --- a/src/rpc/zmq_server.cpp +++ b/src/rpc/zmq_server.cpp @@ -28,10 +28,13 @@ #include "zmq_server.h" +#include <boost/utility/string_ref.hpp> #include <chrono> #include <cstdint> #include <system_error> +#include "byte_slice.h" + namespace cryptonote { @@ -73,10 +76,11 @@ void ZmqServer::serve() { const std::string message = MONERO_UNWRAP(net::zmq::receive(socket.get())); MDEBUG("Received RPC request: \"" << message << "\""); - const std::string& response = handler.handle(message); + epee::byte_slice response = handler.handle(message); - MONERO_UNWRAP(net::zmq::send(epee::strspan<std::uint8_t>(response), socket.get())); - MDEBUG("Sent RPC reply: \"" << response << "\""); + const boost::string_ref response_view{reinterpret_cast<const char*>(response.data()), response.size()}; + MDEBUG("Sending RPC reply: \"" << response_view << "\""); + MONERO_UNWRAP(net::zmq::send(std::move(response), socket.get())); } } catch (const std::system_error& e) |