Skip to content

Commit

Permalink
return info
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan committed Oct 10, 2023
1 parent 525821b commit f20e71d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions core/blockchain/impl/block_tree_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,7 @@ namespace kagome::blockchain {
return std::vector{block};
}

auto best_block = p.tree_->best();
BOOST_ASSERT(best_block != nullptr);
auto current_depth = best_block->info.number;
auto current_depth = bestBlockNoLock(p).number;

if (start_block_number >= current_depth) {
return std::vector{block};
Expand Down Expand Up @@ -1197,7 +1195,7 @@ namespace kagome::blockchain {

primitives::BlockInfo BlockTreeImpl::bestBlockNoLock(
const BlockTreeData &p) const {
return p.tree_->best()->info;
return p.tree_->best();
}

primitives::BlockInfo BlockTreeImpl::bestBlock() const {
Expand Down Expand Up @@ -1271,7 +1269,7 @@ namespace kagome::blockchain {

primitives::BlockInfo BlockTreeImpl::getLastFinalizedNoLock(
const BlockTreeData &p) const {
return p.tree_->finalized()->info;
return p.tree_->finalized();
}

primitives::BlockInfo BlockTreeImpl::getLastFinalized() const {
Expand Down Expand Up @@ -1416,7 +1414,7 @@ namespace kagome::blockchain {

BOOST_ASSERT(!last_pruned.has_value()
|| last_pruned.value().number
<= block_tree_data.tree_->finalized()->info.number);
<= getLastFinalizedNoLock(block_tree_data).number);
auto next_pruned_number = last_pruned ? last_pruned->number + 1 : 0;

OUTCOME_TRY(hash_opt, getBlockHash(next_pruned_number));
Expand Down
8 changes: 4 additions & 4 deletions core/blockchain/impl/cached_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ namespace kagome::blockchain {
best_{root_},
leaves_{root.hash} {}

const std::shared_ptr<TreeNode> &CachedTree::finalized() const {
return root_;
primitives::BlockInfo CachedTree::finalized() const {
return root_->info;
}

const std::shared_ptr<TreeNode> &CachedTree::best() const {
return best_;
primitives::BlockInfo CachedTree::best() const {
return best_->info;
}

size_t CachedTree::leafCount() const {
Expand Down
4 changes: 2 additions & 2 deletions core/blockchain/impl/cached_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace kagome::blockchain {
public:
explicit CachedTree(const primitives::BlockInfo &root);

const std::shared_ptr<TreeNode> &finalized() const;
const std::shared_ptr<TreeNode> &best() const;
primitives::BlockInfo finalized() const;
primitives::BlockInfo best() const;
size_t leafCount() const;
std::vector<primitives::BlockHash> leafHashes() const;
bool isLeaf(const primitives::BlockHash &hash) const;
Expand Down

0 comments on commit f20e71d

Please sign in to comment.