Skip to content

Commit

Permalink
GH-2125 Add and use fetch_bsp
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Mar 7, 2024
1 parent ac27a5e commit 2329a5f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,8 @@ struct controller_impl {
return fork_db.apply<block_state_ptr>(
overloaded{
[](const fork_database_legacy_t&) -> block_state_ptr { return nullptr; },
[&](const fork_database_if_t&forkdb) -> block_state_ptr {
auto bsp = forkdb.search_on_head_branch(block_num, include_root_t::yes);
return bsp;
[&](const fork_database_if_t& forkdb) -> block_state_ptr {
return forkdb.search_on_head_branch(block_num, include_root_t::yes);
}
}
);
Expand All @@ -1074,9 +1073,19 @@ struct controller_impl {
return fork_db.apply<block_state_ptr>(
overloaded{
[](const fork_database_legacy_t&) -> block_state_ptr { return nullptr; },
[&](const fork_database_if_t&forkdb) -> block_state_ptr {
auto bsp = forkdb.search_on_branch(id, block_num, include_root_t::yes);
return bsp;
[&](const fork_database_if_t& forkdb) -> block_state_ptr {
return forkdb.search_on_branch(id, block_num, include_root_t::yes);
}
}
);
}

block_state_ptr fetch_bsp(const block_id_type& id) const {
return fork_db.apply<block_state_ptr>(
overloaded{
[](const fork_database_legacy_t&) -> block_state_ptr { return nullptr; },
[&](const fork_database_if_t& forkdb) -> block_state_ptr {
return forkdb.get_block(id, include_root_t::yes);
}
}
);
Expand Down Expand Up @@ -3478,7 +3487,7 @@ struct controller_impl {

if (bsp->core.final_on_strong_qc_block_num > 0) {
const auto& final_on_strong_qc_block_ref = bsp->core.get_block_reference(bsp->core.final_on_strong_qc_block_num);
auto final = fetch_bsp_on_branch_by_num(final_on_strong_qc_block_ref.block_id, bsp->core.final_on_strong_qc_block_num);
auto final = fetch_bsp(final_on_strong_qc_block_ref.block_id);
if (final && final->is_valid()) {
create_and_send_vote_msg(bsp);
}
Expand Down

0 comments on commit 2329a5f

Please sign in to comment.