diff options
author | Lee Clagett <code@leeclagett.com> | 2020-10-13 15:15:07 +0000 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-10-10 15:28:40 +0000 |
commit | 7414e2bac11cbf9163ca16dc1b1510b4fd9a0d64 (patch) | |
tree | 1cd7aa7394630a8be218534112ba88a5b618d96a /contrib/epee/src | |
parent | Merge pull request #7072 (diff) | |
download | monero-7414e2bac11cbf9163ca16dc1b1510b4fd9a0d64.tar.xz |
Change epee binary output from std::stringstream to byte_stream
Diffstat (limited to 'contrib/epee/src')
-rw-r--r-- | contrib/epee/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | contrib/epee/src/portable_storage.cpp | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index 8adf69162..5e101a86a 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp - int-util.cpp) + int-util.cpp portable_storage.cpp) if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW))) add_library(epee_readline STATIC readline_buffer.cpp) diff --git a/contrib/epee/src/portable_storage.cpp b/contrib/epee/src/portable_storage.cpp new file mode 100644 index 000000000..4534deff3 --- /dev/null +++ b/contrib/epee/src/portable_storage.cpp @@ -0,0 +1,29 @@ + +#include "byte_slice.h" +#include "byte_stream.h" +#include "misc_log_ex.h" +#include "span.h" +#include "storages/portable_storage.h" +#include "storages/portable_storage_to_bin.h" + +namespace epee +{ +namespace serialization +{ + bool portable_storage::store_to_binary(byte_slice& target, const std::size_t initial_buffer_size) + { + TRY_ENTRY(); + byte_stream ss; + ss.reserve(initial_buffer_size); + storage_block_header sbh{}; + sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA); + sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB); + sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER; + ss.write(epee::as_byte_span(sbh)); + pack_entry_to_buff(ss, m_root); + target = epee::byte_slice{std::move(ss)}; + return true; + CATCH_ENTRY("portable_storage::store_to_binary", false) + } +} +} |