From be1f16f7ffa3dd4ad93429f2ae95455765eca516 Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Wed, 30 Oct 2024 08:01:40 +0100 Subject: [PATCH] fix locks --- .../src/pillar_chain/pillar_chain_manager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/core_libs/consensus/src/pillar_chain/pillar_chain_manager.cpp b/libraries/core_libs/consensus/src/pillar_chain/pillar_chain_manager.cpp index bd8257b977..1d58d7b03a 100644 --- a/libraries/core_libs/consensus/src/pillar_chain/pillar_chain_manager.cpp +++ b/libraries/core_libs/consensus/src/pillar_chain/pillar_chain_manager.cpp @@ -109,10 +109,11 @@ std::shared_ptr PillarChainManager::createPillarBlock( void PillarChainManager::saveNewPillarBlock(const std::shared_ptr& pillar_block, std::vector&& new_vote_counts) { db_->saveCurrentPillarBlockData({pillar_block, new_vote_counts}); - - std::scoped_lock lock(mutex_); - current_pillar_block_ = pillar_block; - current_pillar_block_vote_counts_ = std::move(new_vote_counts); + { + std::scoped_lock lock(mutex_); + current_pillar_block_ = pillar_block; + current_pillar_block_vote_counts_ = std::move(new_vote_counts); + } } std::shared_ptr PillarChainManager::genAndPlacePillarVote(PbftPeriod period, @@ -332,7 +333,6 @@ bool PillarChainManager::isValidPillarBlock(const std::shared_ptr& } const auto last_finalized_pillar_block = getLastFinalizedPillarBlock(); - std::shared_lock lock(mutex_); assert(last_finalized_pillar_block); // Check if some block was not skipped