aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-12-10 17:34:50 -0800
committerAlexander Blair <snipa@jagtech.io>2020-12-10 17:34:50 -0800
commit1e9483a2d585d4ce4c2bf001862132ca46185c16 (patch)
treeb9a58d5cd7de6b8ed5da9df1c869449f0623611b /contrib/epee/src
parentMerge pull request #7003 (diff)
parentChange epee binary output from std::stringstream to byte_stream (diff)
downloadmonero-1e9483a2d585d4ce4c2bf001862132ca46185c16.tar.xz
Merge pull request #7009
7414e2bac Change epee binary output from std::stringstream to byte_stream (Lee Clagett)
Diffstat (limited to 'contrib/epee/src')
-rw-r--r--contrib/epee/src/CMakeLists.txt2
-rw-r--r--contrib/epee/src/portable_storage.cpp29
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)
+ }
+}
+}