Skip to content

Commit

Permalink
Merge branch 'dev_master' into testnet
Browse files Browse the repository at this point in the history
* dev_master:
  chore: output replay logs to stderr
  updated fc submodule
  • Loading branch information
zhuliting committed Nov 29, 2018
2 parents 0efccac + 383cf9a commit 545ecc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions libraries/chain/db_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ void database::reindex(fc::path data_dir, bool fast_replay)
}
if( last_block->block_num() <= head_block_num()) return;

ilog( "reindexing blockchain" );
std::cerr << "reindexing blockchain" << std::endl;
auto start = fc::time_point::now();
const auto last_block_num = last_block->block_num();
uint32_t flush_point = last_block_num < 10000 ? 0 : last_block_num - 10000;
uint32_t undo_point = last_block_num < 50 ? 0 : last_block_num - 50;

ilog( "Replaying blocks, starting at ${next}...", ("next",head_block_num() + 1) );
std::cerr << "Replaying blocks, starting at " << head_block_num() + 1 << std::endl;
if( head_block_num() >= undo_point )
{
if( head_block_num() > 0 )
Expand Down Expand Up @@ -100,16 +100,16 @@ void database::reindex(fc::path data_dir, bool fast_replay)
}
if( i == flush_point )
{
ilog( "Writing database to disk at block ${i}", ("i",i) );
std::cerr << "Writing database to disk at block " << i << std::endl;
flush();
ilog( "Done" );
std::cerr << "Done" << std::endl;
}
if( head_block_time() >= last_block->timestamp - gpo.parameters.maximum_time_until_expiration )
skip &= ~skip_transaction_dupe_check;
fc::optional< signed_block > block = _block_id_to_block.fetch_by_number(i);
if( !block.valid() )
{
wlog( "Reindexing terminated due to gap: Block ${i} does not exist!", ("i", i) );
std::cerr << "Reindexing terminated due to gap: Block " << i << " does not exist!";
uint32_t dropped_count = 0;
while( true )
{
Expand All @@ -123,7 +123,7 @@ void database::reindex(fc::path data_dir, bool fast_replay)
_block_id_to_block.remove( *last_id );
dropped_count++;
}
wlog( "Dropped ${n} blocks from after the gap", ("n", dropped_count) );
std::cerr << "Dropped " << dropped_count << " blocks from after the gap";
break;
}
if( i < undo_point )
Expand All @@ -136,12 +136,12 @@ void database::reindex(fc::path data_dir, bool fast_replay)
}
_undo_db.enable();
auto end = fc::time_point::now();
ilog( "Done reindexing, elapsed time: ${t} sec", ("t",double((end-start).count())/1000000.0 ) );
std::cerr << "Done reindexing, elapsed time: " << double((end-start).count())/1000000.0 << " sec";
} FC_CAPTURE_AND_RETHROW( (data_dir) ) }

void database::wipe(const fc::path& data_dir, bool include_blocks)
{
ilog("Wiping database, data_dir ${data_dir} ${include_blocks}", ("data_dir", data_dir)("include_blocks", include_blocks));
std::cerr << "Wiping database, data_dir " << data_dir.generic_string() << " " << include_blocks << std::endl;
if (_opened) {
close();
}
Expand All @@ -168,7 +168,7 @@ void database::open(
wipe_object_db = ( version_string != db_version );
}
if( wipe_object_db ) {
ilog("Wiping object_database due to missing or wrong version");
std::cerr << "Wiping object_database due to missing or wrong version" << std::endl;
object_database::wipe( data_dir );
std::ofstream version_file( (data_dir / "db_version").generic_string().c_str(),
std::ios::out | std::ios::binary | std::ios::trunc );
Expand Down
2 changes: 1 addition & 1 deletion libraries/fc
Submodule fc updated 1 files
+1 −1 src/network/ip.cpp

0 comments on commit 545ecc2

Please sign in to comment.