Kagome
Polkadot Runtime Engine in C++17
offchain_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_OFFCHAIN_OFFCHAINSTORAGE
7 #define KAGOME_OFFCHAIN_OFFCHAINSTORAGE
8 
9 #include <boost/optional.hpp>
10 
11 #include "common/buffer.hpp"
12 #include "outcome/outcome.hpp"
13 
14 namespace kagome::offchain {
15 
21  public:
22  virtual ~OffchainStorage() = default;
23 
30  virtual outcome::result<void> set(const common::BufferView &key,
31  common::Buffer value) = 0;
32 
38  virtual outcome::result<void> clear(const common::BufferView &key) = 0;
39 
48  virtual outcome::result<bool> compare_and_set(
49  const common::BufferView &key,
50  const std::optional<common::BufferView> &expected,
51  common::Buffer value) = 0;
52 
58  virtual outcome::result<common::Buffer> get(
59  const common::BufferView &key) = 0;
60  };
61 
62 } // namespace kagome::offchain
63 
64 #endif // KAGOME_OFFCHAIN_OFFCHAINSTORAGE
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
virtual outcome::result< void > clear(const common::BufferView &key)=0
Remove a value from the local storage.
virtual outcome::result< bool > compare_and_set(const common::BufferView &key, const std::optional< common::BufferView > &expected, common::Buffer value)=0
Sets a new value in the local storage if the condition matches the current value. ...
virtual ~OffchainStorage()=default