Browse Source

Fix for wierd empty blocks.

cl-refactor
Gav Wood 10 years ago
parent
commit
3cb6af930f
  1. 12
      libethereum/BlockChain.cpp
  2. 2
      libethereum/EthereumPeer.cpp

12
libethereum/BlockChain.cpp

@ -276,7 +276,10 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
auto pd = details(bi.parentHash);
if (!pd)
{
cwarn << "Odd: details is returning false despite block known:" << RLP(pd.rlp());
cwarn << "Block:" << RLP(block(bi.parentHash));
}
// Check it's not crazy
if (bi.timestamp > (u256)time(0))
@ -479,13 +482,16 @@ bytes BlockChain::block(h256 _hash) const
string d;
m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d);
if (!d.size())
{
cwarn << "Couldn't find requested block:" << _hash.abridged();
return d;
}
WriteGuard l(x_cache);
m_cache[_hash].resize(d.size());
memcpy(m_cache[_hash].data(), d.data(), d.size());
if (!d.size())
cwarn << "Couldn't find requested block:" << _hash.abridged();
return m_cache[_hash];
}

2
libethereum/EthereumPeer.cpp

@ -203,7 +203,7 @@ bool EthereumPeer::interpret(RLP const& _r)
for (unsigned i = 1; i < _r.itemCount(); ++i)
{
auto h = _r[i].toHash<h256>();
if (host()->m_chain.details(h))
if (host()->m_chain.isKnown(h))
{
host()->noteHaveChain(this);
return true;

Loading…
Cancel
Save