Kagome
Polkadot Runtime Engine in C++17
offchain_persistent_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_OFFCHAIN_OFFCHAINPERSISTENTSTORAGEIMPL
7 #define KAGOME_OFFCHAIN_OFFCHAINPERSISTENTSTORAGEIMPL
8 
10 
11 #include "log/logger.hpp"
13 
14 namespace kagome::offchain {
15 
17  public:
19  std::shared_ptr<storage::BufferStorage> storage);
20 
21  outcome::result<void> set(const common::BufferView &key,
22  common::Buffer value) override;
23 
24  outcome::result<void> clear(const common::BufferView &key) override;
25 
26  outcome::result<bool> compare_and_set(
27  const common::BufferView &key,
28  const std::optional<common::BufferView> &expected,
29  common::Buffer value) override;
30 
31  outcome::result<common::Buffer> get(const common::BufferView &key) override;
32 
33  private:
34  std::shared_ptr<storage::BufferStorage> storage_;
35 
36  std::mutex mutex_;
38  };
39 
40 } // namespace kagome::offchain
41 
42 #endif // KAGOME_OFFCHAIN_OFFCHAINPERSISTENTSTORAGEIMPL
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
OffchainPersistentStorageImpl(std::shared_ptr< storage::BufferStorage > storage)
outcome::result< void > clear(const common::BufferView &key) override
Remove a value from the local storage.
It is non-revertible and not fork-aware. It means that any value set by the offchain worker is persis...
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
outcome::result< bool > compare_and_set(const common::BufferView &key, const std::optional< common::BufferView > &expected, common::Buffer value) override
Sets a new value in the local storage if the condition matches the current value. ...
std::shared_ptr< storage::BufferStorage > storage_