diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index 46fb18988..3d15f2992 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -496,6 +496,7 @@ ConsensusExtFace::transactions_vector SkaleHost::pendingTransactions( u256 gasAcc = 0; auto first_to_drop_it = txns.begin(); for ( ; first_to_drop_it != txns.end(); ++first_to_drop_it ) { + // TODO log something here!? gasAcc += first_to_drop_it->gas(); if ( gasAcc > blockGasLimit ) break; @@ -593,6 +594,8 @@ ConsensusExtFace::transactions_vector SkaleHost::pendingTransactions( void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _approvedTransactions, uint64_t _timeStamp, uint64_t _blockID, u256 _gasPrice, u256 _stateRoot, uint64_t _winningNodeIndex ) try { + unlock_guard< std::timed_mutex > unlocker( m_consensusWorkingMutex ); + // static std::atomic_size_t g_nCreateBlockTaskNumber = 0; size_t nCreateBlockTaskNumber = g_nCreateBlockTaskNumber++; @@ -762,8 +765,13 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro m_consensus->exitGracefully(); ExitHandler::exitHandler( SIGTERM, ExitHandler::ec_rotation_complete ); clog( VerbosityInfo, "skale-host" ) << "Rotation is completed. Instance is exiting"; + unlocker.will_exit(); } } + + if ( m_exitNeeded ) + unlocker.will_exit(); + } catch ( const std::exception& ex ) { cerror << "CRITICAL " << ex.what() << " (in createBlock)"; cerror << "\n" << skutils::signal::generate_stack_trace() << "\n" << std::endl;