Allow restarting block production with dummy checkpoint

This commit is contained in:
Vikram Rajkumar 2015-08-17 13:52:45 -04:00
parent 3a7e65c888
commit 73cc012db9
3 changed files with 10 additions and 18 deletions

2
docs

@ -1 +1 @@
Subproject commit cdc8ea8133a999afef8051700a4ce8edb0988ec4
Subproject commit f42a917c0cb93784567d649be60d610469c33ee0

View file

@ -357,26 +357,14 @@ const vector<operation_history_object>& database::get_applied_operations() const
void database::apply_block( const signed_block& next_block, uint32_t skip )
{
auto block_num = next_block.block_num();
if( _checkpoints.size() )
if( _checkpoints.size() && _checkpoints.rbegin()->second != block_id_type() )
{
auto itr = _checkpoints.find( block_num );
if( itr != _checkpoints.end() )
FC_ASSERT( next_block.id() == itr->second, "Block did not match checkpoint", ("checkpoint",*itr)("block_id",next_block.id()) );
auto last = _checkpoints.rbegin();
if( last->first >= block_num )
{
// WE CAN SKIP ALMOST EVERYTHING
skip = ~0;
/** clear the recently missed count because the checkpoint indicates that
* we will never have to go back further than this.
*/
const auto& _dgp = dynamic_global_property_id_type(0)(*this);
modify( _dgp, [&]( dynamic_global_property_object& dgp ){
dgp.recently_missed_count = 0;
});
}
if( _checkpoints.rbegin()->first >= block_num )
skip = ~0;// WE CAN SKIP ALMOST EVERYTHING
}
with_skip_flags( skip, [&]()

View file

@ -49,8 +49,12 @@ void database::update_global_dynamic_data( const signed_block& b )
fc::raw::pack( enc, b.previous_secret );
dgp.random = enc.result();
if( missed_blocks )
dgp.recently_missed_count += 2*missed_blocks;
if( _checkpoints.size() && _checkpoints.rbegin()->first >= b.block_num() )
dgp.recently_missed_count = 0;
else if( missed_blocks )
dgp.recently_missed_count += 4*missed_blocks;
else if( dgp.recently_missed_count > 4 )
dgp.recently_missed_count -= 3;
else if( dgp.recently_missed_count > 0 )
dgp.recently_missed_count--;