blob: 8aebc653846a284364e06036e46afe081e4575a0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include "InMemoryBackend.h"
#include <picosha2.h>
namespace nt {
std::string InMemoryBackend::Put(std::vector<uint8_t> value) {
const std::string hash = picosha2::hash256_hex_string(value.begin(), value.end());
kv_.emplace(hash, std::move(value));
return hash;
}
std::optional<std::vector<uint8_t>> InMemoryBackend::Get(const std::string& hash) {
auto it = kv_.find(hash);
if (it == kv_.end())
return std::nullopt;
return it->second;
}
} // namespace nt
|