Skip to content

Commit

Permalink
GH-525 Minor cleanup from PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Dec 15, 2022
1 parent 9b1401a commit 8f12805
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 5 additions & 6 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,14 +2057,14 @@ struct controller_impl {
} FC_CAPTURE_AND_RETHROW() } /// apply_block


block_state_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b, const block_header_state_ptr& prev ) {
block_state_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b, const block_header_state& prev ) {
auto trx_mroot = calculate_trx_merkle( b->transactions );
EOS_ASSERT( b->transaction_mroot == trx_mroot, block_validate_exception,
"invalid block transaction merkle root ${b} != ${c}", ("b", b->transaction_mroot)("c", trx_mroot) );

const bool skip_validate_signee = false;
auto bsp = std::make_shared<block_state>(
*prev,
prev,
b,
protocol_features.get_protocol_feature_set(),
[this]( block_timestamp_type timestamp,
Expand All @@ -2091,19 +2091,18 @@ struct controller_impl {
EOS_ASSERT( prev, unlinkable_block_exception,
"unlinkable block ${id}", ("id", id)("previous", b->previous) );

return control->create_block_state( id, b, prev );
return control->create_block_state( id, b, *prev );
} );
}

block_state_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b ) {
EOS_ASSERT( b, block_validate_exception, "null block" );

block_state_ptr bsp;
// previous not found could mean that previous block not applied yet
auto prev = fork_db.get_block_header( b->previous );
if( !prev ) return bsp;
if( !prev ) return {};

return create_block_state( id, b, prev );
return create_block_state( id, b, *prev );
}

void push_block( const block_state_ptr& bsp,
Expand Down
4 changes: 1 addition & 3 deletions libraries/chain/fork_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,7 @@ namespace eosio { namespace chain {
}

for( const auto& block_id : remove_queue ) {
auto itr = index.find( block_id );
if( itr != index.end() )
index.erase(itr);
index.erase( block_id );
}
}

Expand Down

0 comments on commit 8f12805

Please sign in to comment.