@ -384,52 +384,49 @@ tuple<ImportRoute, bool, unsigned> BlockChain::sync(BlockQueue& _bq, OverlayDB c
Transactions goodTransactions ;
Transactions goodTransactions ;
unsigned count = 0 ;
unsigned count = 0 ;
for ( VerifiedBlock const & block : blocks )
for ( VerifiedBlock const & block : blocks )
if ( ! badBlocks . empty ( ) )
{
badBlocks . push_back ( block . verified . info . hash ( ) ) ;
do {
else
try
{
{
do {
// Nonce & uncle nonces already verified in verification thread at this point.
try
ImportRoute r ;
{
DEV_TIMED_ABOVE ( " Block import " + toString ( block . verified . info . number ( ) ) , 500 )
// Nonce & uncle nonces already verified in verification thread at this point.
r = import ( block . verified , _stateDB , ImportRequirements : : Everything & ~ ImportRequirements : : ValidSeal & ~ ImportRequirements : : CheckUncles ) ;
ImportRoute r ;
fresh + = r . liveBlocks ;
DEV_TIMED_ABOVE ( " Block import " + toString ( block . verified . info . number ( ) ) , 500 )
dead + = r . deadBlocks ;
r = import ( block . verified , _stateDB , ImportRequirements : : Everything & ~ ImportRequirements : : ValidSeal & ~ ImportRequirements : : CheckUncles ) ;
goodTransactions . reserve ( goodTransactions . size ( ) + r . goodTranactions . size ( ) ) ;
fresh + = r . liveBlocks ;
std : : move ( std : : begin ( r . goodTranactions ) , std : : end ( r . goodTranactions ) , std : : back_inserter ( goodTransactions ) ) ;
dead + = r . deadBlocks ;
+ + count ;
goodTransactions . reserve ( goodTransactions . size ( ) + r . goodTranactions . size ( ) ) ;
}
std : : move ( std : : begin ( r . goodTranactions ) , std : : end ( r . goodTranactions ) , std : : back_inserter ( goodTransactions ) ) ;
catch ( dev : : eth : : UnknownParent )
+ + count ;
{
}
cwarn < < " ODD: Import queue contains block with unknown parent. " ; // << LogTag::Error << boost::current_exception_diagnostic_information();
catch ( dev : : eth : : UnknownParent )
// NOTE: don't reimport since the queue should guarantee everything in the right order.
{
// Can't continue - chain bad.
cwarn < < " ODD: Import queue contains block with unknown parent. " ; // << LogTag::Error << boost::current_exception_diagnostic_information();
badBlocks . push_back ( block . verified . info . hash ( ) ) ;
// NOTE: don't reimport since the queue should guarantee everything in the right order.
}
// Can't continue - chain bad.
catch ( dev : : eth : : FutureTime )
badBlocks . push_back ( block . verified . info . hash ( ) ) ;
{
}
cwarn < < " ODD: Import queue contains a block with future time. " ;
catch ( dev : : eth : : FutureTime )
this_thread : : sleep_for ( chrono : : seconds ( 1 ) ) ;
{
continue ;
cwarn < < " ODD: Import queue contains a block with future time. " ;
}
this_thread : : sleep_for ( chrono : : seconds ( 1 ) ) ;
catch ( dev : : eth : : TransientError )
continue ;
{
}
this_thread : : sleep_for ( chrono : : milliseconds ( 100 ) ) ;
catch ( dev : : eth : : TransientError )
continue ;
{
}
this_thread : : sleep_for ( chrono : : milliseconds ( 100 ) ) ;
catch ( Exception & ex )
continue ;
{
}
// cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!";// << LogTag::Error << diagnostic_information(ex);
catch ( Exception & ex )
if ( m_onBad )
{
m_onBad ( ex ) ;
// cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!";// << LogTag::Error << diagnostic_information(ex);
// NOTE: don't reimport since the queue should guarantee everything in the right order.
if ( m_onBad )
// Can't continue - chain bad.
m_onBad ( ex ) ;
badBlocks . push_back ( block . verified . info . hash ( ) ) ;
// NOTE: don't reimport since the queue should guarantee everything in the right order.
}
// Can't continue - chain bad.
} while ( false ) ;
badBlocks . push_back ( block . verified . info . hash ( ) ) ;
}
}
} while ( false ) ;
}
return make_tuple ( ImportRoute { dead , fresh , goodTransactions } , _bq . doneDrain ( badBlocks ) , count ) ;
return make_tuple ( ImportRoute { dead , fresh , goodTransactions } , _bq . doneDrain ( badBlocks ) , count ) ;
}
}