Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework move semantics little bit #2877

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading