Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
optional
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan committed Jul 29, 2022
commit 2b945ecab1e16631e1a1e93b3b8d1c78f0fb5891
2 changes: 1 addition & 1 deletion core/api/service/impl/api_service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace kagome::api {
void ApiServiceImpl::onStorageEvent(SubscriptionSetId set_id,
SessionPtr &session,
const Buffer &key,
const Buffer &data,
const std::optional<Buffer> &data,
const common::Hash256 &block) {
sendEvent(server_,
session,
Expand Down
2 changes: 1 addition & 1 deletion core/api/service/impl/api_service_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ namespace kagome::api {
void onStorageEvent(SubscriptionSetId set_id,
SessionPtr &session,
const Buffer &key,
const Buffer &data,
const std::optional<Buffer> &data,
const common::Hash256 &block);
void onChainEvent(SubscriptionSetId set_id,
SessionPtr &session,
Expand Down
2 changes: 1 addition & 1 deletion core/primitives/event_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace kagome::primitives::events {
using StorageSubscriptionEngine =
subscription::SubscriptionEngine<common::Buffer,
std::shared_ptr<api::Session>,
common::Buffer,
std::optional<common::Buffer>,
primitives::BlockHash>;
using StorageSubscriptionEnginePtr =
std::shared_ptr<StorageSubscriptionEngine>;
Expand Down
13 changes: 7 additions & 6 deletions core/storage/changes_trie/impl/storage_changes_tracker_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ namespace kagome::storage::changes_trie {
primitives::events::ChainEventType::kNewRuntime, hash);
}
for (auto &pair : actual_val_) {
SL_TRACE(logger_,
"Key: 0x{}; Value 0x{};",
pair.first.toHex(),
pair.second.toHex());
if (pair.second) {
SL_TRACE(logger_, "Key: {:l}; Value {:l};", pair.first, *pair.second);
} else {
SL_TRACE(logger_, "Key: {:l}; Removed;", pair.first);
}
storage_subscription_engine_->notify(
pair.first, pair.second, parent_hash_);
}
Expand All @@ -71,7 +72,7 @@ namespace kagome::storage::changes_trie {
&& prefix.size() <= static_cast<ssize_t>(it->first.size())
&& it->first.view(0, prefix.size()) == prefix;
++it) {
it->second.clear();
it->second.reset();
}
}

Expand Down Expand Up @@ -101,7 +102,7 @@ namespace kagome::storage::changes_trie {
outcome::result<void> StorageChangesTrackerImpl::onRemove(
common::BufferView extrinsic_index, const common::BufferView &key) {
if (auto it = actual_val_.find(key); it != actual_val_.end()) {
it->second.clear();
it->second.reset();
}

auto change_it = extrinsics_changes_.find(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ namespace kagome::storage::changes_trie {
std::set<common::Buffer, std::less<>>
new_entries_; // entries that do not yet exist in
// the underlying storage
std::map<common::Buffer, common::Buffer, std::less<>> actual_val_;
std::map<common::Buffer, std::optional<common::Buffer>, std::less<>>
actual_val_;

primitives::BlockHash parent_hash_;
primitives::BlockNumber parent_number_;
Expand Down