diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 6d26984d..facf19d5 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -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, diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index be39b48a..82a88227 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -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 ////////////////////