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,13 +168,15 @@ void database::open(
FC_CAPTURE_LOG_AND_RETHROW( (data_dir) ) 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() // TODO: Save pending tx's on close()
clear_pending(); clear_pending();
// pop all of the blocks that we can given our undo history, this should // pop all of the blocks that we can given our undo history, this should
// throw when there is no more undo history to pop // throw when there is no more undo history to pop
if( rewind )
{
try try
{ {
while( true ) while( true )
@ -195,6 +197,7 @@ void database::close(uint32_t blocks_to_rewind)
catch (...) catch (...)
{ {
} }
}
// Since pop_block() will move tx's in the popped blocks into pending, // Since pop_block() will move tx's in the popped blocks into pending,
// we have to clear_pending() after we're done popping to get a clean // we have to clear_pending() after we're done popping to get a clean

View file

@ -100,7 +100,7 @@ namespace graphene { namespace chain {
* Will close the database before wiping. Database will be closed when this function returns. * 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 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 //////////////////// //////////////////// db_block.cpp ////////////////////