Browse Source

Queue diagnostics.

cl-refactor
Gav Wood 10 years ago
parent
commit
f50af8e10e
  1. 13
      libethereum/BlockQueue.cpp

13
libethereum/BlockQueue.cpp

@ -33,11 +33,16 @@ bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
// Check if we already know this block.
h256 h = sha3(_block);
cnote << "Queuing block" << h.abridged() << "for import...";
UpgradableGuard l(m_lock);
if (m_readySet.count(h) || m_drainingSet.count(h) || m_futureSet.count(h))
{
// Already know about this one.
cnote << "Already known.";
return false;
}
// VERIFY: populates from the block and checks the block is internally coherent.
BlockInfo bi;
@ -60,11 +65,17 @@ bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
// Check block doesn't already exist first!
if (_bc.details(newHash))
{
cnote << "Already known in chain.";
return false;
}
// Check it's not crazy
if (bi.timestamp > (u256)time(0))
{
cnote << "Invalid timestamp.";
return false;
}
{
UpgradeGuard ul(l);
@ -73,12 +84,14 @@ bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
if (!m_readySet.count(bi.parentHash) && !m_drainingSet.count(bi.parentHash) && !_bc.details(bi.parentHash))
{
// We don't know the parent (yet) - queue it up for later. It'll get resent to us if we find out about its ancestry later on.
cnote << "OK - queued for future.";
m_future.insert(make_pair(bi.parentHash, make_pair(h, _block.toBytes())));
m_futureSet.insert(h);
}
else
{
// If valid, append to blocks.
cnote << "OK - ready for chain insertion.";
m_ready.push_back(_block.toBytes());
m_readySet.insert(h);

Loading…
Cancel
Save