From b97b503408911130d24d7f07f9247dca8314a316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 1 Jan 2020 21:27:11 +0100 Subject: Respond to data requests from network --- include/erebos/storage.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include/erebos/storage.h') diff --git a/include/erebos/storage.h b/include/erebos/storage.h index 95a4574..edb0aca 100644 --- a/include/erebos/storage.h +++ b/include/erebos/storage.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -183,7 +184,15 @@ public: Object(Variants content): content(content) {} Object & operator=(const Object &) = delete; + static std::optional::const_iterator>> + decodePrefix(Storage, std::vector::const_iterator, + std::vector::const_iterator); + static std::optional decode(Storage, const std::vector &); + static std::optional decode(Storage, + std::vector::const_iterator, + std::vector::const_iterator); + static std::vector decodeMany(Storage, const std::vector &); std::vector encode() const; static std::optional load(const Ref &); @@ -297,3 +306,16 @@ bool Stored::precedes(const Stored & other) const } } + +namespace std +{ + template<> struct hash + { + std::size_t operator()(const erebos::Digest & dgst) const noexcept + { + std::size_t res; + std::memcpy(&res, dgst.arr().data(), sizeof res); + return res; + } + }; +} -- cgit v1.2.3