Browse Source

Merge branch 'release-poc-3' into develop

Conflicts:
	libethereum/Common.h
cl-refactor
Gav Wood 11 years ago
parent
commit
b020c0d50c
  1. 2
      libethereum/BlockInfo.cpp
  2. 4
      libethereum/Exceptions.h
  3. 16
      libethereum/RLP.cpp
  4. 3
      libethereum/RLP.h

2
libethereum/BlockInfo.cpp

@ -101,7 +101,7 @@ void BlockInfo::populateFromHeader(RLP const& _header)
extraData = _header[field = 7].toBytes();
nonce = _header[field = 8].toHash<h256>();
}
catch (RLP::BadCast)
catch (RLPException const&)
{
throw InvalidBlockHeaderFormat(field, _header[field].data());
}

4
libethereum/Exceptions.h

@ -16,6 +16,10 @@ public:
class BadHexCharacter: public Exception {};
class NotEnoughCash: public Exception {};
class RLPException: public Exception {};
class BadCast: public RLPException {};
class BadRLP: public RLPException {};
class VMException: public Exception {};
class StepsDone: public VMException {};
class BreakPointHit: public VMException {};

16
libethereum/RLP.cpp

@ -102,9 +102,17 @@ bool RLP::isInt() const
else if (n == c_rlpDataImmLenStart)
return true;
else if (n <= c_rlpDataIndLenZero)
{
if (m_data.size() <= 1)
throw BadRLP();
return m_data[1] != 0;
}
else if (n < c_rlpListStart)
{
if ((int)m_data.size() <= 1 + n - c_rlpDataIndLenZero)
throw BadRLP();
return m_data[1 + n - c_rlpDataIndLenZero] != 0;
}
else
return false;
return false;
@ -121,13 +129,21 @@ eth::uint RLP::length() const
else if (n <= c_rlpDataIndLenZero)
return n - c_rlpDataImmLenStart;
else if (n < c_rlpListStart)
{
if ((int)m_data.size() <= n - c_rlpDataIndLenZero)
throw BadRLP();
for (int i = 0; i < n - c_rlpDataIndLenZero; ++i)
ret = (ret << 8) | m_data[i + 1];
}
else if (n <= c_rlpListIndLenZero)
return n - c_rlpListStart;
else
{
if ((int)m_data.size() <= n - c_rlpListIndLenZero)
throw BadRLP();
for (int i = 0; i < n - c_rlpListIndLenZero; ++i)
ret = (ret << 8) | m_data[i + 1];
}
return ret;
}

3
libethereum/RLP.h

@ -30,6 +30,7 @@
#include <iomanip>
#include "vector_ref.h"
#include "Common.h"
#include "Exceptions.h"
namespace eth
{
@ -60,8 +61,6 @@ static const byte c_rlpListIndLenZero = c_rlpListStart + c_rlpListImmLenCount -
class RLP
{
public:
class BadCast: public std::exception {};
/// Construct a null node.
RLP() {}

Loading…
Cancel
Save