fork_database don't assert on last pop_block during DB close
This commit is contained in:
parent
948624df2a
commit
7cbd9139d7
5 changed files with 13 additions and 8 deletions
|
|
@ -585,14 +585,16 @@ signed_block database::_generate_block(
|
||||||
* Removes the most recent block from the database and
|
* Removes the most recent block from the database and
|
||||||
* undoes any changes it made.
|
* undoes any changes it made.
|
||||||
*/
|
*/
|
||||||
void database::pop_block()
|
void database::pop_block(bool check)
|
||||||
{ try {
|
{ try {
|
||||||
_pending_tx_session.reset();
|
_pending_tx_session.reset();
|
||||||
auto head_id = head_block_id();
|
auto head_id = head_block_id();
|
||||||
optional<signed_block> head_block = fetch_block_by_id( head_id );
|
optional<signed_block> head_block = fetch_block_by_id( head_id );
|
||||||
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
|
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
|
||||||
|
|
||||||
_fork_db.pop_block();
|
ilog( "head_block is ${dump}", ("dump", head_block) );
|
||||||
|
|
||||||
|
_fork_db.pop_block(check);
|
||||||
pop_undo();
|
pop_undo();
|
||||||
|
|
||||||
_popped_tx.insert( _popped_tx.begin(), head_block->transactions.begin(), head_block->transactions.end() );
|
_popped_tx.insert( _popped_tx.begin(), head_block->transactions.begin(), head_block->transactions.end() );
|
||||||
|
|
|
||||||
|
|
@ -259,11 +259,12 @@ void database::close(bool rewind)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uint32_t cutoff = get_dynamic_global_properties().last_irreversible_block_num;
|
uint32_t cutoff = get_dynamic_global_properties().last_irreversible_block_num;
|
||||||
|
//ilog("cutoff = ${c}", ("c", cutoff));
|
||||||
while( head_block_num() > cutoff )
|
while( head_block_num() > cutoff )
|
||||||
{
|
{
|
||||||
|
//ilog("head_block_num() = ${id}", ("id", head_block_num()));
|
||||||
block_id_type popped_block_id = head_block_id();
|
block_id_type popped_block_id = head_block_id();
|
||||||
pop_block();
|
pop_block( head_block_num() == cutoff + 1 ? false : true);
|
||||||
_fork_db.remove(popped_block_id); // doesn't throw on missing
|
_fork_db.remove(popped_block_id); // doesn't throw on missing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,13 @@ void fork_database::reset()
|
||||||
_index.clear();
|
_index.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fork_database::pop_block()
|
void fork_database::pop_block(bool check)
|
||||||
{
|
{
|
||||||
FC_ASSERT( _head, "no blocks to pop" );
|
FC_ASSERT( _head, "no blocks to pop" );
|
||||||
auto prev = _head->prev.lock();
|
auto prev = _head->prev.lock();
|
||||||
FC_ASSERT( prev, "poping block would leave head block null" );
|
if (check){
|
||||||
|
FC_ASSERT( prev, "poping block would leave head block null" );
|
||||||
|
}
|
||||||
_head = prev;
|
_head = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace graphene { namespace chain {
|
||||||
const fc::ecc::private_key& block_signing_private_key
|
const fc::ecc::private_key& block_signing_private_key
|
||||||
);
|
);
|
||||||
|
|
||||||
void pop_block();
|
void pop_block(bool check = true);
|
||||||
void clear_pending();
|
void clear_pending();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ namespace graphene { namespace chain {
|
||||||
*/
|
*/
|
||||||
shared_ptr<fork_item> push_block(const signed_block& b);
|
shared_ptr<fork_item> push_block(const signed_block& b);
|
||||||
shared_ptr<fork_item> head()const { return _head; }
|
shared_ptr<fork_item> head()const { return _head; }
|
||||||
void pop_block();
|
void pop_block(bool check);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given two head blocks, return two branches of the fork graph that
|
* Given two head blocks, return two branches of the fork graph that
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue