Add byte_stream for zero-copy serialization, and add support in ZMQ-JSON.

This commit is contained in:
Lee Clagett 2020-03-18 23:22:39 +00:00
parent 8185054db7
commit c26c93019a
14 changed files with 806 additions and 171 deletions

View file

@ -3,10 +3,10 @@
#include <boost/range/adaptor/indexed.hpp>
#include <gtest/gtest.h>
#include <rapidjson/document.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <vector>
#include "byte_stream.h"
#include "crypto/hash.h"
#include "cryptonote_basic/account.h"
#include "cryptonote_basic/cryptonote_basic.h"
@ -86,14 +86,14 @@ namespace
template<typename T>
T test_json(const T& value)
{
rapidjson::StringBuffer buffer;
epee::byte_stream buffer;
{
rapidjson::Writer<rapidjson::StringBuffer> dest{buffer};
rapidjson::Writer<epee::byte_stream> dest{buffer};
cryptonote::json::toJsonValue(dest, value);
}
rapidjson::Document doc;
doc.Parse(buffer.GetString());
doc.Parse(reinterpret_cast<const char*>(buffer.data()), buffer.size());
if (doc.HasParseError() || !doc.IsObject())
{
throw cryptonote::json::PARSE_FAIL();