Skip to content

Commit

Permalink
Fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrm committed Jul 24, 2023
1 parent 0488f75 commit 8cd5694
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/consensus/babe/impl/babe_config_repository_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ namespace kagome::consensus::babe {
}

bool BabeConfigRepositoryImpl::prepare() {
std::unique_lock lock{indexer_mutex_};
auto finalized = block_tree_->getLastFinalized();
auto finalized_header = block_tree_->getBlockHeader(finalized.hash).value();
if (finalized.number - indexer_.last_finalized_indexed_.number

primitives::BlockNumber indexer_last_finalized;
{
std::unique_lock lock{indexer_mutex_};
indexer_last_finalized = indexer_.last_finalized_indexed_.number;
}

if (finalized.number - indexer_last_finalized
> kMaxUnindexedBlocksNum
and trie_storage_->getEphemeralBatchAt(finalized_header.state_root)) {
warp(finalized);
Expand Down

0 comments on commit 8cd5694

Please sign in to comment.