diff options
author | Lee Clagett <code@leeclagett.com> | 2020-03-18 23:22:39 +0000 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-04-11 04:12:11 +0000 |
commit | c26c93019a52dee52ee865f4f1b23e6929968258 (patch) | |
tree | e17353bec4084e7c502921eea3169e22b7f125e1 /src/rpc/message.cpp | |
parent | Merge pull request #6451 (diff) | |
download | monero-c26c93019a52dee52ee865f4f1b23e6929968258.tar.xz |
Add byte_stream for zero-copy serialization, and add support in ZMQ-JSON.
Diffstat (limited to 'src/rpc/message.cpp')
-rw-r--r-- | src/rpc/message.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rpc/message.cpp b/src/rpc/message.cpp index 0d8983cb1..fffb44921 100644 --- a/src/rpc/message.cpp +++ b/src/rpc/message.cpp @@ -62,7 +62,7 @@ const rapidjson::Value& get_method_field(const rapidjson::Value& src) } } -void Message::toJson(rapidjson::Writer<rapidjson::StringBuffer>& dest) const +void Message::toJson(rapidjson::Writer<epee::byte_stream>& dest) const { dest.StartObject(); INSERT_INTO_JSON_OBJECT(dest, status, status); @@ -151,9 +151,9 @@ cryptonote::rpc::error FullMessage::getError() epee::byte_slice FullMessage::getRequest(const std::string& request, const Message& message, const unsigned id) { - rapidjson::StringBuffer buffer; + epee::byte_stream buffer; { - rapidjson::Writer<rapidjson::StringBuffer> dest{buffer}; + rapidjson::Writer<epee::byte_stream> dest{buffer}; dest.StartObject(); INSERT_INTO_JSON_OBJECT(dest, jsonrpc, (boost::string_ref{"2.0", 3})); @@ -172,15 +172,15 @@ epee::byte_slice FullMessage::getRequest(const std::string& request, const Messa if (!dest.IsComplete()) throw std::logic_error{"Invalid JSON tree generated"}; } - return epee::byte_slice{{buffer.GetString(), buffer.GetSize()}}; + return epee::byte_slice{std::move(buffer)}; } epee::byte_slice FullMessage::getResponse(const Message& message, const rapidjson::Value& id) { - rapidjson::StringBuffer buffer; + epee::byte_stream buffer; { - rapidjson::Writer<rapidjson::StringBuffer> dest{buffer}; + rapidjson::Writer<epee::byte_stream> dest{buffer}; dest.StartObject(); INSERT_INTO_JSON_OBJECT(dest, jsonrpc, (boost::string_ref{"2.0", 3})); @@ -207,7 +207,7 @@ epee::byte_slice FullMessage::getResponse(const Message& message, const rapidjso if (!dest.IsComplete()) throw std::logic_error{"Invalid JSON tree generated"}; } - return epee::byte_slice{{buffer.GetString(), buffer.GetSize()}}; + return epee::byte_slice{std::move(buffer)}; } // convenience functions for bad input |