Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change replay percentage to total block size processed #1289 #1335

Merged
merged 5 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions libraries/chain/block_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,15 @@ optional<block_id_type> block_database::last_id()const
return optional<block_id_type>();
}

size_t block_database::blocks_current_position()const
{
return (size_t)_blocks.tellg();
}

size_t block_database::total_block_size()const
{
_blocks.seekg( 0, _blocks.end );
return (size_t)_blocks.tellg();
}

} }
12 changes: 11 additions & 1 deletion libraries/chain/db_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,19 @@ void database::reindex( fc::path data_dir )
skip_tapos_check |
skip_witness_schedule_check |
skip_authority_check;

size_t total_processed_block_size;
size_t total_block_size = _block_id_to_block.total_block_size();
for( uint32_t i = head_block_num() + 1; i <= last_block_num; ++i )
{
if( i % 10000 == 0 ) std::cerr << " " << double(i*100)/last_block_num << "% "<<i << " of " <<last_block_num<<" \n";
if( i % 10000 == 0 )
{
total_processed_block_size = _block_id_to_block.blocks_current_position();

std::cerr << " "
<< double(total_processed_block_size*100) / total_block_size << "% "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this won't overflow? Still a bit uncomfortable with it.

By the way, perhaps better to show the block number as well?

<< total_processed_block_size << " of " << total_block_size << " \n";
}
if( i == flush_point )
{
ilog( "Writing database to disk at block ${i}", ("i",i) );
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/graphene/chain/block_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace graphene { namespace chain {
optional<signed_block> fetch_by_number( uint32_t block_num )const;
optional<signed_block> last()const;
optional<block_id_type> last_id()const;
size_t blocks_current_position()const;
size_t total_block_size()const;
private:
optional<index_entry> last_index_entry()const;
fc::path _index_filename;
Expand Down