Skip to content

Commit

Permalink
GH-1941 Remove fetch_block_state_by_number()
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Dec 21, 2023
1 parent b5c6cc0 commit eddea59
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3636,7 +3636,7 @@ std::optional<signed_block_header> controller::fetch_block_header_by_id( const b
}

signed_block_ptr controller::fetch_block_by_number( uint32_t block_num )const { try {
auto blk_state = fetch_block_state_by_number( block_num );
auto blk_state = my->fork_db.search_on_branch( fork_db_head_block_id(), block_num );
if( blk_state ) {
return blk_state->block;
}
Expand All @@ -3645,7 +3645,7 @@ signed_block_ptr controller::fetch_block_by_number( uint32_t block_num )const {
} FC_CAPTURE_AND_RETHROW( (block_num) ) }

std::optional<signed_block_header> controller::fetch_block_header_by_number( uint32_t block_num )const { try {
auto blk_state = fetch_block_state_by_number( block_num );
auto blk_state = my->fork_db.search_on_branch( fork_db_head_block_id(), block_num );
if( blk_state ) {
return blk_state->header;
}
Expand All @@ -3658,17 +3658,13 @@ block_state_legacy_ptr controller::fetch_block_state_by_id( block_id_type id )co
return state;
}

block_state_legacy_ptr controller::fetch_block_state_by_number( uint32_t block_num )const { try {
return my->fork_db.search_on_branch( fork_db_head_block_id(), block_num );
} FC_CAPTURE_AND_RETHROW( (block_num) ) }

block_id_type controller::get_block_id_for_num( uint32_t block_num )const { try {
const auto& blog_head = my->blog.head();

bool find_in_blog = (blog_head && block_num <= blog_head->block_num());

if( !find_in_blog ) {
auto bsp = fetch_block_state_by_number( block_num );
auto bsp = my->fork_db.search_on_branch( fork_db_head_block_id(), block_num );
if( bsp ) return bsp->id();
}

Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/hotstuff/chain_pacemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ namespace eosio::chain {
// called from main thread
void chain_pacemaker::on_accepted_block( const signed_block_ptr& block ) {
std::scoped_lock g( _chain_state_mutex );
_head_block_state = _chain->fetch_block_state_by_number(block->block_num());
// TODO: assume this is going away
_head_block_state = _chain->head_block_state_legacy();
}

// called from main thread
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ namespace eosio::chain {
// thread-safe
std::optional<signed_block_header> fetch_block_header_by_id( const block_id_type& id )const;
// return block_state_legacy from forkdb, thread-safe
block_state_legacy_ptr fetch_block_state_by_number( uint32_t block_num )const;
// return block_state_legacy from forkdb, thread-safe
block_state_legacy_ptr fetch_block_state_by_id( block_id_type id )const;
// thread-safe
block_id_type get_block_id_for_num( uint32_t block_num )const;
Expand Down

0 comments on commit eddea59

Please sign in to comment.