Browse Source

Make bad protocol disconnects a bit more obvious.

cl-refactor
Gav Wood 10 years ago
parent
commit
1faaed3395
  1. 2
      libethereum/BlockChain.cpp
  2. 8
      libethereum/EthereumPeer.cpp
  3. 4
      libp2p/Session.cpp

2
libethereum/BlockChain.cpp

@ -439,7 +439,7 @@ void BlockChain::checkConsistency()
h256 h((byte const*)it->key().data(), h256::ConstructFromPointer);
auto dh = details(h);
auto p = dh.parent;
if (p != h256() && p != m_genesisHash)
if (p != h256() && p != m_genesisHash) // TODO: for some reason the genesis details with the children get squished. not sure why.
{
auto dp = details(p);
if (asserts(contains(dp.children, h)))

8
libethereum/EthereumPeer.cpp

@ -288,6 +288,8 @@ void EthereumPeer::attemptSync()
bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
{
try
{
switch (_id)
{
case StatusPacket:
@ -509,5 +511,11 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r)
default:
return false;
}
}
catch (std::exception const& _e)
{
clogS(NetWarn) << "Peer causing an exception:" << _e.what() << _r;
}
return true;
}

4
libp2p/Session.cpp

@ -297,6 +297,7 @@ bool Session::interpret(RLP const& _r)
peerAddress = bi::address_v4(_r[i][0].toHash<FixedHash<4>>().asArray());
else
{
cwarn << "Received bad peer packet:" << _r;
disconnect(BadProtocol);
return true;
}
@ -372,7 +373,7 @@ bool Session::interpret(RLP const& _r)
}
catch (std::exception const& _e)
{
clogS(NetWarn) << "Peer causing an exception:" << _e.what();
clogS(NetWarn) << "Peer causing an exception:" << _e.what() << _r;
disconnect(BadProtocol);
return true;
}
@ -579,6 +580,7 @@ void Session::doRead()
if (!interpret(r))
{
// error - bad protocol
clogS(NetWarn) << "Couldn't interpret packet." << RLP(r);
disconnect(BadProtocol);
return;
}

Loading…
Cancel
Save