Skip to content

Commit

Permalink
Merge pull request #2877 from Taraxa-project/fix-potencial-issue-with…
Browse files Browse the repository at this point in the history
…-move

rework move semantics little bit
  • Loading branch information
MatusKysel authored Oct 30, 2024
2 parents 409ac0b + 1a8277c commit bfa3f7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class PillarChainManager {
* @param pillar_block
* @param new_vote_counts
*/
void saveNewPillarBlock(std::shared_ptr<PillarBlock> pillar_block,
void saveNewPillarBlock(const std::shared_ptr<PillarBlock>& pillar_block,
std::vector<state_api::ValidatorVoteCount>&& new_vote_counts);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,12 @@ std::shared_ptr<PillarBlock> PillarChainManager::createPillarBlock(
return pillar_block;
}

void PillarChainManager::saveNewPillarBlock(std::shared_ptr<PillarBlock> pillar_block,
void PillarChainManager::saveNewPillarBlock(const std::shared_ptr<PillarBlock>& pillar_block,
std::vector<state_api::ValidatorVoteCount>&& new_vote_counts) {
CurrentPillarBlockDataDb data{std::move(pillar_block), std::move(new_vote_counts)};
db_->saveCurrentPillarBlockData(data);

std::scoped_lock<std::shared_mutex> lock(mutex_);
current_pillar_block_ = std::move(data.pillar_block);
current_pillar_block_vote_counts_ = std::move(data.vote_counts);
db_->saveCurrentPillarBlockData({pillar_block, new_vote_counts});
current_pillar_block_ = pillar_block;
current_pillar_block_vote_counts_ = std::move(new_vote_counts);
}

std::shared_ptr<PillarVote> PillarChainManager::genAndPlacePillarVote(PbftPeriod period,
Expand Down Expand Up @@ -333,7 +331,6 @@ bool PillarChainManager::isValidPillarBlock(const std::shared_ptr<PillarBlock>&
}

const auto last_finalized_pillar_block = getLastFinalizedPillarBlock();
std::shared_lock<std::shared_mutex> lock(mutex_);
assert(last_finalized_pillar_block);

// Check if some block was not skipped
Expand Down

0 comments on commit bfa3f7e

Please sign in to comment.