Kagome
Polkadot Runtime Engine in C++17
trie_storage_backend_batch.cpp
Go to the documentation of this file.
1 
7 
8 namespace kagome::storage::trie {
9 
12  storage_batch,
13  common::Buffer node_prefix)
14  : storage_batch_{std::move(storage_batch)},
15  node_prefix_{std::move(node_prefix)} {
16  BOOST_ASSERT(storage_batch_ != nullptr);
17  }
18 
19  outcome::result<void> TrieStorageBackendBatch::commit() {
20  return storage_batch_->commit();
21  }
22 
24  storage_batch_->clear();
25  }
26 
27  outcome::result<void> TrieStorageBackendBatch::put(
28  const common::BufferView &key, const common::Buffer &value) {
29  return storage_batch_->put(prefixKey(key), value);
30  }
31 
32  outcome::result<void> TrieStorageBackendBatch::put(
33  const common::BufferView &key, common::Buffer &&value) {
34  return storage_batch_->put(prefixKey(key), std::move(value));
35  }
36 
37  outcome::result<void> TrieStorageBackendBatch::remove(
38  const common::BufferView &key) {
39  return storage_batch_->remove(prefixKey(key));
40  }
41 
43  const common::BufferView &key) const {
44  auto prefixed_key = node_prefix_;
45  prefixed_key.put(key);
46  return prefixed_key;
47  }
48 
49 } // namespace kagome::storage::trie
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
TrieStorageBackendBatch(std::unique_ptr< face::WriteBatch< common::BufferView, common::Buffer >> storage_batch, common::Buffer node_prefix)
SLBuffer & put(std::string_view view)
Put a string into byte buffer.
Definition: buffer.hpp:117
outcome::result< void > commit() override
Writes batch.
outcome::result< void > put(const common::BufferView &key, const common::Buffer &value) override
Store value by key.
outcome::result< void > remove(const common::BufferView &key) override
Remove value by key.
common::Buffer prefixKey(const common::BufferView &key) const
std::unique_ptr< face::WriteBatch< common::BufferView, common::Buffer > > storage_batch_