Browse Source

Don't grab queue up blocks we already know about.

cl-refactor
Gav Wood 10 years ago
parent
commit
292c35ce49
  1. 3
      libethcore/Common.h
  2. 3
      libethereum/BlockQueue.h
  3. 5
      libethereum/EthereumPeer.cpp

3
libethcore/Common.h

@ -90,7 +90,8 @@ enum class ImportResult
AlreadyInChain,
AlreadyKnown,
Malformed,
BadChain
BadChain,
Unknown
};
struct ImportRequirements

3
libethereum/BlockQueue.h

@ -86,6 +86,9 @@ public:
/// Get some infomration on the current status.
BlockQueueStatus status() const { ReadGuard l(m_lock); return BlockQueueStatus{m_ready.size(), m_future.size(), m_unknown.size(), m_knownBad.size()}; }
/// Get some infomration on the given block's status regarding us.
ImportResult blockStatus(h256 const& _h) const { ReadGuard l(m_lock); return m_readySet.count(_h) || m_drainingSet.count(_h) ? ImportResult::AlreadyKnown : m_unknownSet.count(_h) ? ImportResult::UnknownParent : m_knownBad.count(_h) ? ImportResult::BadChain : ImportResult::Unknown; }
template <class T> Handler onReady(T const& _t) { return m_onReady.add(_t); }
private:

5
libethereum/EthereumPeer.cpp

@ -389,7 +389,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
{
addRating(1);
auto h = _r[i].toHash<h256>();
if (host()->m_chain.isKnown(h))
if (host()->m_bq.blockStatus(h) != ImportResult::Unknown || host()->m_chain.isKnown(h))
{
transition(Asking::Blocks);
return true;
@ -484,6 +484,8 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
case ImportResult::UnknownParent:
unknown++;
break;
default:;
}
}
else
@ -535,6 +537,7 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
clog(NetMessageSummary) << "Received block with no known parent. Resyncing...";
setNeedsSyncing(h, _r[1].toInt<u256>());
break;
default:;
}
Guard l(x_knownBlocks);

Loading…
Cancel
Save