Skip to content

Commit

Permalink
Removed packed_block #675
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vandeberg committed Dec 12, 2016
1 parent e21d608 commit f409f75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
27 changes: 4 additions & 23 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ optional<signed_block> database::fetch_block_by_id( const block_id_type& id )con
auto b = _fork_db.fetch_block( id );
if( !b )
{
auto tmp = fetch_block_by_number( protocol::block_header::num_from_id( id ) );
auto tmp = _block_log.read_block_by_num( protocol::block_header::num_from_id( id ) );

if( tmp && tmp->id() == id )
return tmp;
Expand All @@ -264,21 +264,11 @@ optional<signed_block> database::fetch_block_by_number( uint32_t block_num )cons
{
optional< signed_block > b;

const auto* stats = find< block_stats_object >( block_num - 1 );

if( !stats )
return b;

if( stats->packed_block.size() )
{
signed_block block;
fc::raw::unpack( stats->packed_block, block );
b = block;
}
auto results = _fork_db.fetch_block_by_number( block_num );
if( results.size() == 1 )
b = results[0]->data;
else
{
b = _block_log.read_block_by_num( block_num );
}

return b;
}
Expand Down Expand Up @@ -3050,8 +3040,6 @@ void database::_apply_block( const signed_block& next_block )
{
assert( bso.block_num() == next_block_num ); // Probably can be taken out. Sanity check
bso.block_id = next_block_id;
if( !( get_node_properties().skip_flags & skip_block_log ) )
fc::raw::pack( bso.packed_block, next_block );
});

update_global_dynamic_data(next_block);
Expand Down Expand Up @@ -3542,13 +3530,6 @@ void database::update_last_irreversible_block()
while( log_head_num < dpo.last_irreversible_block_num )
{
_block_log.append( *fetch_block_by_number( log_head_num + 1 ) );

// Block stats object IDs are block num - 1, so the ID is ( log_head_num + 1 ) - 1
modify( get< block_stats_object >( log_head_num ), [&]( block_stats_object& bso )
{
bso.packed_block.clear();
});

log_head_num++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ namespace steemit { namespace chain {
public:
template< typename Constructor, typename Allocator >
block_stats_object( Constructor&& c, allocator< Allocator > a )
:packed_block( a )
{
c( *this );
}

id_type id;
block_id_type block_id;
bip::vector< char, allocator< char > > packed_block;

uint64_t block_num()const { return id._id + 1; }
};
Expand All @@ -73,5 +71,5 @@ namespace steemit { namespace chain {
FC_REFLECT( steemit::chain::block_summary_object, (id)(block_id) )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::block_summary_object, steemit::chain::block_summary_index )

FC_REFLECT( steemit::chain::block_stats_object, (id)(block_id)(packed_block) )
FC_REFLECT( steemit::chain::block_stats_object, (id)(block_id) )
CHAINBASE_SET_INDEX_TYPE( steemit::chain::block_stats_object, steemit::chain::block_stats_index )

0 comments on commit f409f75

Please sign in to comment.