Skip to content

Commit

Permalink
Temporary add cached block tree in injector
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsa committed Oct 25, 2024
1 parent 4e6f4ec commit b2c54ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/injector/application_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ namespace {

template <typename Injector>
sptr<blockchain::BlockTree> get_block_tree(const Injector &injector) {
static std::optional<sptr<blockchain::BlockTree>> cached = std::nullopt;
if (cached.has_value()) {
return cached.value();
}
auto chain_events_engine =
injector
.template create<primitives::events::ChainSubscriptionEnginePtr>();
Expand Down Expand Up @@ -372,6 +376,7 @@ namespace {
runtime_upgrade_tracker->subscribeToBlockchainEvents(chain_events_engine,
block_tree);

cached = block_tree;
return block_tree;
}

Expand Down

0 comments on commit b2c54ea

Please sign in to comment.