35 bug fix: when blockchain replay is attempted blocks file increases in size #614

Merged
pavel.baykov merged 1 commit from bug/35-blockchain_replay into develop 2021-12-01 21:57:46 +00:00
3 changed files with 18 additions and 0 deletions

View file

@ -76,6 +76,10 @@ void block_database::flush()
void block_database::store( const block_id_type& _id, const signed_block& b )
{
if (true == replay_mode){
return;
}
block_id_type id = _id;
if( id == block_id_type() )
{
@ -271,4 +275,9 @@ optional<block_id_type> block_database::last_id()const
return optional<block_id_type>();
}
void block_database::set_replay_mode(bool mode)
{
replay_mode = mode;
}
} }

View file

@ -232,7 +232,12 @@ void database::open(
FC_ASSERT( *last_block >= head_block_id(),
"last block ID does not match current chain state",
("last_block->id", last_block)("head_block_id",head_block_num()) );
_block_id_to_block.set_replay_mode(true);
reindex( data_dir );
_block_id_to_block.set_replay_mode(false);
}
_opened = true;
}

View file

@ -47,7 +47,11 @@ 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;
void set_replay_mode(bool mode);
private:
bool replay_mode = false;
optional<index_entry> last_index_entry()const;
fc::path _index_filename;
mutable std::fstream _blocks;