Kagome
Polkadot Runtime Engine in C++17
storage_changes_tracker_impl.cpp
Go to the documentation of this file.
2 
4 
6 
9  storage_subscription_engine,
10  primitives::events::ChainSubscriptionEnginePtr chain_subscription_engine)
11  : storage_subscription_engine_(std::move(storage_subscription_engine)),
12  chain_subscription_engine_(std::move(chain_subscription_engine)),
13  logger_{log::createLogger("Storage Changes Tracker", "changes_trie")} {}
14 
16  primitives::BlockHash new_parent_hash) {
17  parent_hash_ = new_parent_hash;
18  // new block -- new extrinsics
19  actual_val_.clear();
20  new_entries_.clear();
21  }
22 
24  const primitives::BlockHash &hash) {
25  if (actual_val_.find(storage::kRuntimeCodeKey) != actual_val_.cend()) {
28  }
29  for (auto &pair : actual_val_) {
30  if (pair.second) {
31  SL_TRACE(logger_, "Key: {:l}; Value {:l};", pair.first, *pair.second);
32  } else {
33  SL_TRACE(logger_, "Key: {:l}; Removed;", pair.first);
34  }
36  pair.first, pair.second, parent_hash_);
37  }
38  }
39 
41  const common::BufferView &value,
42  bool is_new_entry) {
43  auto it = actual_val_.find(key);
44  if (it != actual_val_.end()) {
45  it->second.emplace(value);
46  } else {
47  actual_val_.emplace(key, value);
48  if (is_new_entry) {
49  new_entries_.insert(common::Buffer{key});
50  }
51  }
52  }
53 
55  if (auto it = actual_val_.find(key); it != actual_val_.end()) {
56  if (new_entries_.erase(it->first) != 0) {
57  actual_val_.erase(it);
58  } else {
59  it->second.reset();
60  }
61  }
62  }
63 } // namespace kagome::storage::changes_trie
Class represents arbitrary (including empty) byte buffer.
Definition: buffer.hpp:29
void onPut(const common::BufferView &key, const common::BufferView &value, bool new_entry) override
primitives::events::ChainSubscriptionEnginePtr chain_subscription_engine_
std::shared_ptr< StorageSubscriptionEngine > StorageSubscriptionEnginePtr
void onBlockAdded(const primitives::BlockHash &hash) override
std::map< common::Buffer, std::optional< common::Buffer >, std::less<> > actual_val_
STL namespace.
std::shared_ptr< ChainSubscriptionEngine > ChainSubscriptionEnginePtr
primitives::events::StorageSubscriptionEnginePtr storage_subscription_engine_
void onBlockExecutionStart(primitives::BlockHash new_parent_hash) override
StorageChangesTrackerImpl(primitives::events::StorageSubscriptionEnginePtr storage_subscription_engine, primitives::events::ChainSubscriptionEnginePtr chain_subscription_engine)
Logger createLogger(const std::string &tag)
Definition: logger.cpp:112
const common::Buffer kRuntimeCodeKey