db_management.cpp: Allow us to skip rewind on close()

This commit is contained in:
theoreticalbts 2015-10-08 15:00:27 -04:00
parent 5b4398fb44
commit 43a2660143
2 changed files with 19 additions and 16 deletions

View file

@ -168,32 +168,35 @@ void database::open(
FC_CAPTURE_LOG_AND_RETHROW( (data_dir) )
}
void database::close(uint32_t blocks_to_rewind)
void database::close(bool rewind)
{
// TODO: Save pending tx's on close()
clear_pending();
// pop all of the blocks that we can given our undo history, this should
// throw when there is no more undo history to pop
try
if( rewind )
{
while( true )
try
{
// elog("pop");
block_id_type popped_block_id = head_block_id();
pop_block();
_fork_db.remove(popped_block_id); // doesn't throw on missing
try
{
_block_id_to_block.remove(popped_block_id);
}
catch (const fc::key_not_found_exception&)
while( true )
{
// elog("pop");
block_id_type popped_block_id = head_block_id();
pop_block();
_fork_db.remove(popped_block_id); // doesn't throw on missing
try
{
_block_id_to_block.remove(popped_block_id);
}
catch (const fc::key_not_found_exception&)
{
}
}
}
}
catch (...)
{
catch (...)
{
}
}
// Since pop_block() will move tx's in the popped blocks into pending,

View file

@ -100,7 +100,7 @@ namespace graphene { namespace chain {
* Will close the database before wiping. Database will be closed when this function returns.
*/
void wipe(const fc::path& data_dir, bool include_blocks);
void close(uint32_t blocks_to_rewind = 0);
void close(bool rewind = true);
//////////////////// db_block.cpp ////////////////////