Merge branch 'bug/35-blockchain_replay' into 'develop'
35 bug fix: when blockchain replay is attempted blocks file increases in size See merge request PBSA/peerplays!34
This commit is contained in:
commit
92e017e3b0
3 changed files with 18 additions and 0 deletions
|
|
@ -76,6 +76,10 @@ void block_database::flush()
|
||||||
|
|
||||||
void block_database::store( const block_id_type& _id, const signed_block& b )
|
void block_database::store( const block_id_type& _id, const signed_block& b )
|
||||||
{
|
{
|
||||||
|
if (true == replay_mode){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
block_id_type id = _id;
|
block_id_type id = _id;
|
||||||
if( id == block_id_type() )
|
if( id == block_id_type() )
|
||||||
{
|
{
|
||||||
|
|
@ -271,4 +275,9 @@ optional<block_id_type> block_database::last_id()const
|
||||||
return optional<block_id_type>();
|
return optional<block_id_type>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void block_database::set_replay_mode(bool mode)
|
||||||
|
{
|
||||||
|
replay_mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,12 @@ void database::open(
|
||||||
FC_ASSERT( *last_block >= head_block_id(),
|
FC_ASSERT( *last_block >= head_block_id(),
|
||||||
"last block ID does not match current chain state",
|
"last block ID does not match current chain state",
|
||||||
("last_block->id", last_block)("head_block_id",head_block_num()) );
|
("last_block->id", last_block)("head_block_id",head_block_num()) );
|
||||||
|
|
||||||
|
_block_id_to_block.set_replay_mode(true);
|
||||||
|
|
||||||
reindex( data_dir );
|
reindex( data_dir );
|
||||||
|
|
||||||
|
_block_id_to_block.set_replay_mode(false);
|
||||||
}
|
}
|
||||||
_opened = true;
|
_opened = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,11 @@ namespace graphene { namespace chain {
|
||||||
optional<signed_block> fetch_by_number( uint32_t block_num )const;
|
optional<signed_block> fetch_by_number( uint32_t block_num )const;
|
||||||
optional<signed_block> last()const;
|
optional<signed_block> last()const;
|
||||||
optional<block_id_type> last_id()const;
|
optional<block_id_type> last_id()const;
|
||||||
|
|
||||||
|
void set_replay_mode(bool mode);
|
||||||
private:
|
private:
|
||||||
|
bool replay_mode = false;
|
||||||
|
|
||||||
optional<index_entry> last_index_entry()const;
|
optional<index_entry> last_index_entry()const;
|
||||||
fc::path _index_filename;
|
fc::path _index_filename;
|
||||||
mutable std::fstream _blocks;
|
mutable std::fstream _blocks;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue