Browse Source

Merge branch 'develop' into quickgui

cl-refactor
Gav Wood 11 years ago
parent
commit
e7fb427efb
  1. 2
      .gitignore
  2. 6
      CMakeLists.txt
  3. 5
      TODO
  4. 2
      libethereum/BlockInfo.cpp
  5. 4
      libethereum/Exceptions.h
  6. 16
      libethereum/RLP.cpp
  7. 3
      libethereum/RLP.h

2
.gitignore

@ -20,3 +20,5 @@ ipch
*.suo
*.user
*.user.*
*~

6
CMakeLists.txt

@ -143,6 +143,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories(/usr/local/lib)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Generate header file containing useful build information
execute_process(COMMAND git --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git --work-tree=${CMAKE_CURRENT_SOURCE_DIR} rev-parse HEAD OUTPUT_VARIABLE commit_hash OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Commit Hash: ${commit_hash}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildInfo.h "// This file was automatically generated by cmake\n#pragma once\n\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/BuildInfo.h "#define COMMIT_HASH \"${commit_hash}\"\n")
add_subdirectory(secp256k1)
add_subdirectory(libethereum)
add_subdirectory(test)

5
TODO

@ -41,6 +41,8 @@ General:
Robustness
- Remove aborts
- Recover from all exceptions.
- Especially RLP & other I/O.
- RLP should never assert; only throw.
- Store version alongside BC DB.
- Better handling of corrupt blocks.
- Kill DB & restart.
@ -52,9 +54,6 @@ GUI
- Qt/QML class.
- Turn on/off debug channels.
For PoC3:
- Shared contract acceptence tests.
### Marko

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