db_management.cpp: Allow us to skip rewind on close()
This commit is contained in:
parent
5b4398fb44
commit
43a2660143
2 changed files with 19 additions and 16 deletions
|
|
@ -168,32 +168,35 @@ 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
|
||||||
try
|
if( rewind )
|
||||||
{
|
{
|
||||||
while( true )
|
try
|
||||||
{
|
{
|
||||||
// elog("pop");
|
while( true )
|
||||||
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&)
|
|
||||||
{
|
{
|
||||||
|
// 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,
|
// Since pop_block() will move tx's in the popped blocks into pending,
|
||||||
|
|
|
||||||
|
|
@ -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 ////////////////////
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue