|
@ -315,41 +315,44 @@ tuple<h256s, h256s, bool> BlockChain::sync(BlockQueue& _bq, OverlayDB const& _st |
|
|
h256s fresh; |
|
|
h256s fresh; |
|
|
h256s dead; |
|
|
h256s dead; |
|
|
h256s badBlocks; |
|
|
h256s badBlocks; |
|
|
for (auto const& block: blocks) |
|
|
for (VerifiedBlock const& block: blocks) |
|
|
{ |
|
|
if (!badBlocks.empty()) |
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
// Nonce & uncle nonces already verified in verification thread at this point.
|
|
|
|
|
|
ImportRoute r; |
|
|
|
|
|
DEV_TIMED_ABOVE(Block import, 500) |
|
|
|
|
|
r = import(block.verified, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidNonce & ~ImportRequirements::CheckUncles); |
|
|
|
|
|
fresh += r.first; |
|
|
|
|
|
dead += r.second; |
|
|
|
|
|
} |
|
|
|
|
|
catch (dev::eth::UnknownParent) |
|
|
|
|
|
{ |
|
|
|
|
|
cwarn << "ODD: Import queue contains block with unknown parent." << LogTag::Error << boost::current_exception_diagnostic_information(); |
|
|
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the right order.
|
|
|
|
|
|
// Can't continue - chain bad.
|
|
|
|
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
} |
|
|
else |
|
|
catch (dev::eth::FutureTime) |
|
|
|
|
|
{ |
|
|
|
|
|
cwarn << "ODD: Import queue contains a block with future time." << LogTag::Error << boost::current_exception_diagnostic_information(); |
|
|
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the past.
|
|
|
|
|
|
// Can't continue - chain bad.
|
|
|
|
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception& ex) |
|
|
|
|
|
{ |
|
|
{ |
|
|
cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!" << LogTag::Error << diagnostic_information(ex); |
|
|
try |
|
|
if (m_onBad) |
|
|
{ |
|
|
m_onBad(ex); |
|
|
// Nonce & uncle nonces already verified in verification thread at this point.
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the right order.
|
|
|
ImportRoute r; |
|
|
// Can't continue - chain bad.
|
|
|
DEV_TIMED_ABOVE(Block import, 500) |
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
r = import(block.verified, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidNonce & ~ImportRequirements::CheckUncles); |
|
|
|
|
|
fresh += r.first; |
|
|
|
|
|
dead += r.second; |
|
|
|
|
|
} |
|
|
|
|
|
catch (dev::eth::UnknownParent) |
|
|
|
|
|
{ |
|
|
|
|
|
cwarn << "ODD: Import queue contains block with unknown parent." << LogTag::Error << boost::current_exception_diagnostic_information(); |
|
|
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the right order.
|
|
|
|
|
|
// Can't continue - chain bad.
|
|
|
|
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (dev::eth::FutureTime) |
|
|
|
|
|
{ |
|
|
|
|
|
cwarn << "ODD: Import queue contains a block with future time." << LogTag::Error << boost::current_exception_diagnostic_information(); |
|
|
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the past.
|
|
|
|
|
|
// Can't continue - chain bad.
|
|
|
|
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception& ex) |
|
|
|
|
|
{ |
|
|
|
|
|
cnote << "Exception while importing block. Someone (Jeff? That you?) seems to be giving us dodgy blocks!" << LogTag::Error << diagnostic_information(ex); |
|
|
|
|
|
if (m_onBad) |
|
|
|
|
|
m_onBad(ex); |
|
|
|
|
|
// NOTE: don't reimport since the queue should guarantee everything in the right order.
|
|
|
|
|
|
// Can't continue - chain bad.
|
|
|
|
|
|
badBlocks.push_back(block.verified.info.hash()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return make_tuple(fresh, dead, _bq.doneDrain(badBlocks)); |
|
|
return make_tuple(fresh, dead, _bq.doneDrain(badBlocks)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|