Skip to content

Commit

Permalink
GH-1991 emit irreversible signal afer fork db is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Dec 16, 2023
1 parent 846a418 commit f1dc942
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ struct controller_impl {
apply_block( br, *bitr, controller::block_status::complete, trx_meta_cache_lookup{} );
}

emit( self.irreversible_block, *bitr );

// blog.append could fail due to failures like running out of space.
// Do it before commit so that in case it throws, DB can be rolled back.
blog.append( (*bitr)->block, (*bitr)->id, it->get() );
Expand All @@ -461,6 +459,11 @@ struct controller_impl {
} catch( std::exception& ) {
if( root_id != fork_db.root()->id ) {
fork_db.advance_root( root_id );
for( auto bitr = branch.rbegin(); bitr != branch.rend(); ++bitr) {
emit( self.irreversible_block, *bitr );
if ((*bitr)->id == root_id)
break;
}
}
throw;
}
Expand All @@ -470,6 +473,10 @@ struct controller_impl {
if( root_id != fork_db.root()->id ) {
branch.emplace_back(fork_db.root());
fork_db.advance_root( root_id );
// signal after fork_db is updated
for( auto bitr = branch.rbegin(); bitr != branch.rend(); ++bitr) {
emit( self.irreversible_block, *bitr );
}
}

// delete branch in thread pool
Expand Down

0 comments on commit f1dc942

Please sign in to comment.