Browse Source

Split out libethcore from libethereum.

cl-refactor
Gav Wood 11 years ago
parent
commit
648fbc57c9
  1. 1
      CMakeLists.txt
  2. 1
      alethzero/CMakeLists.txt
  3. 2
      alethzero/MainWin.h
  4. 3
      eth/CMakeLists.txt
  5. 14
      eth/main.cpp
  6. 73
      libethcore/CMakeLists.txt
  7. 0
      libethcore/Common.cpp
  8. 0
      libethcore/Common.h
  9. 0
      libethcore/CommonData.cpp
  10. 0
      libethcore/CommonData.h
  11. 0
      libethcore/CommonIO.cpp
  12. 0
      libethcore/CommonIO.h
  13. 2
      libethcore/CryptoHeaders.h
  14. 27
      libethcore/Exceptions.h
  15. 0
      libethcore/FileSystem.cpp
  16. 0
      libethcore/FileSystem.h
  17. 65
      libethcore/FixedHash.cpp
  18. 26
      libethcore/FixedHash.h
  19. 0
      libethcore/Log.cpp
  20. 0
      libethcore/Log.h
  21. 0
      libethcore/RLP.cpp
  22. 1
      libethcore/RLP.h
  23. 0
      libethcore/TrieCommon.cpp
  24. 0
      libethcore/TrieCommon.h
  25. 0
      libethcore/TrieDB.cpp
  26. 3
      libethcore/TrieDB.h
  27. 2
      libethcore/UPnP.cpp
  28. 0
      libethcore/UPnP.h
  29. 0
      libethcore/vector_ref.h
  30. 4
      libethereum/AddressState.h
  31. 6
      libethereum/BlockChain.cpp
  32. 2
      libethereum/BlockChain.h
  33. 4
      libethereum/BlockInfo.cpp
  34. 2
      libethereum/BlockInfo.h
  35. 73
      libethereum/CMakeLists.txt
  36. 2
      libethereum/Client.cpp
  37. 2
      libethereum/Client.h
  38. 43
      libethereum/CommonEth.cpp
  39. 31
      libethereum/CommonEth.h
  40. 4
      libethereum/Dagger.cpp
  41. 1
      libethereum/Dagger.h
  42. 2
      libethereum/Defaults.cpp
  43. 2
      libethereum/Defaults.h
  44. 24
      libethereum/Exceptions.h
  45. 2
      libethereum/ExtVMFace.h
  46. 2
      libethereum/FeeStructure.h
  47. 25
      libethereum/FixedHash.cpp
  48. 2
      libethereum/Instruction.cpp
  49. 2
      libethereum/Instruction.h
  50. 4
      libethereum/PeerNetwork.h
  51. 4
      libethereum/PeerServer.cpp
  52. 2
      libethereum/PeerSession.cpp
  53. 2
      libethereum/PeerSession.h
  54. 2
      libethereum/State.cpp
  55. 6
      libethereum/State.h
  56. 6
      libethereum/Transaction.cpp
  57. 2
      libethereum/Transaction.h
  58. 6
      libethereum/TransactionQueue.cpp
  59. 2
      libethereum/TransactionQueue.h
  60. 2
      libqethereum/QEthereum.cpp
  61. 2
      libqethereum/QEthereum.h
  62. 3
      neth/CMakeLists.txt
  63. 14
      neth/main.cpp
  64. 4
      test/CMakeLists.txt
  65. 4
      test/MemTrie.cpp
  66. 4
      test/MemTrie.h
  67. 2
      test/TestHelper.cpp
  68. 4
      test/TrieHash.cpp
  69. 4
      test/TrieHash.h
  70. 10
      test/crypto.cpp
  71. 4
      test/dagger.cpp
  72. 6
      test/fork.cpp
  73. 4
      test/hexPrefix.cpp
  74. 2
      test/main.cpp
  75. 6
      test/network.cpp
  76. 4
      test/peer.cpp
  77. 6
      test/rlp.cpp
  78. 8
      test/state.cpp
  79. 2
      test/trie.cpp
  80. 6
      test/txTest.cpp
  81. 10
      test/vm.cpp
  82. 1
      walleth/CMakeLists.txt
  83. 2
      walleth/MainWin.cpp

1
CMakeLists.txt

@ -197,6 +197,7 @@ add_custom_target(BuildInfo.h ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/Build
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(secp256k1)
add_subdirectory(libethcore)
add_subdirectory(libethereum)
add_subdirectory(test)
add_subdirectory(eth)

1
alethzero/CMakeLists.txt

@ -9,6 +9,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST)
include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
link_directories(../libqethereum)

2
alethzero/MainWin.h

@ -6,9 +6,9 @@
#include <QtCore/QAbstractListModel>
#include <QtCore/QMutex>
#include <QtWidgets/QMainWindow>
#include <libethcore/RLP.h>
#include <libethereum/CommonEth.h>
#include <libethereum/State.h>
#include <libethereum/RLP.h>
#include <libqethereum/QEthereum.h>
namespace Ui {

3
eth/CMakeLists.txt

@ -2,7 +2,8 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
include_directories(../libethereum)
include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
add_executable(eth ${SRC_LIST})

14
eth/main.cpp

@ -24,13 +24,13 @@
#include <chrono>
#include <fstream>
#include <iostream>
#include "Defaults.h"
#include "Client.h"
#include "PeerNetwork.h"
#include "BlockChain.h"
#include "State.h"
#include "FileSystem.h"
#include "Instruction.h"
#include <libethcore/FileSystem.h>
#include <libethereum/Defaults.h>
#include <libethereum/Client.h>
#include <libethereum/PeerNetwork.h>
#include <libethereum/BlockChain.h>
#include <libethereum/State.h>
#include <libethereum/Instruction.h>
#include "BuildInfo.h"
using namespace std;
using namespace eth;

73
libethcore/CMakeLists.txt

@ -0,0 +1,73 @@
cmake_policy(SET CMP0015 NEW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB")
aux_source_directory(. SRC_LIST)
set(EXECUTABLE ethcore)
if(APPLE)
# set(CMAKE_INSTALL_PREFIX ../lib)
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
else()
add_library(${EXECUTABLE} ${SRC_LIST})
endif()
if (UNIX)
FIND_PACKAGE(Boost 1.53 REQUIRED COMPONENTS thread date_time system filesystem program_options signals serialization chrono unit_test_framework locale)
endif()
file(GLOB HEADERS "*.h")
include_directories(..)
target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} miniupnpc)
target_link_libraries(${EXECUTABLE} leveldb)
target_link_libraries(${EXECUTABLE} gmp)
if(${TARGET_PLATFORM} STREQUAL "w64")
include_directories(/usr/x86_64-w64-mingw32/include/cryptopp)
target_link_libraries(${EXECUTABLE} cryptopp)
target_link_libraries(${EXECUTABLE} boost_system-mt-s)
target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s)
target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s)
target_link_libraries(${EXECUTABLE} iphlpapi)
target_link_libraries(${EXECUTABLE} ws2_32)
target_link_libraries(${EXECUTABLE} mswsock)
target_link_libraries(${EXECUTABLE} shlwapi)
elseif (APPLE)
# Latest mavericks boost libraries only come with -mt
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} boost_system-mt)
target_link_libraries(${EXECUTABLE} boost_filesystem-mt)
target_link_libraries(${EXECUTABLE} boost_thread-mt)
find_package(Threads REQUIRED)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
elseif (UNIX)
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARY})
target_link_libraries(${EXECUTABLE} leveldb)
# target_link_libraries(${EXECUTABLE} snappy)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
else ()
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} boost_system)
target_link_libraries(${EXECUTABLE} boost_filesystem)
target_link_libraries(${EXECUTABLE} boost_thread)
find_package(Threads REQUIRED)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories(/usr/local/lib)
include_directories(/usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message("Installation path: ${CMAKE_INSTALL_PREFIX}")
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

0
libethereum/Common.cpp → libethcore/Common.cpp

0
libethereum/Common.h → libethcore/Common.h

0
libethereum/CommonData.cpp → libethcore/CommonData.cpp

0
libethereum/CommonData.h → libethcore/CommonData.h

0
libethereum/CommonIO.cpp → libethcore/CommonIO.cpp

0
libethereum/CommonIO.h → libethcore/CommonIO.h

2
libethereum/CryptoHeaders.h → libethcore/CryptoHeaders.h

@ -31,6 +31,6 @@
#include <sha.h>
#include <sha3.h>
#include <ripemd.h>
#include <secp256k1.h>
#include <secp256k1/secp256k1.h>
#pragma warning(pop)
#pragma GCC diagnostic pop

27
libethcore/Exceptions.h

@ -0,0 +1,27 @@
#pragma once
#include <exception>
#include "CommonIO.h"
#include "CommonData.h"
#include "FixedHash.h"
namespace eth
{
class Exception: public std::exception
{
public:
virtual std::string description() const { return typeid(*this).name(); }
virtual char const* what() const noexcept { return typeid(*this).name(); }
};
class BadHexCharacter: public Exception {};
class RLPException: public Exception {};
class BadCast: public RLPException {};
class BadRLP: public RLPException {};
class NoNetworking: public Exception {};
class NoUPnPDevice: public Exception {};
class RootNotFound: public Exception {};
}

0
libethereum/FileSystem.cpp → libethcore/FileSystem.cpp

0
libethereum/FileSystem.h → libethcore/FileSystem.h

65
libethcore/FixedHash.cpp

@ -0,0 +1,65 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file FixedHash.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "FixedHash.h"
#include "CryptoHeaders.h"
using namespace std;
using namespace eth;
std::string eth::sha3(std::string const& _input, bool _hex)
{
if (!_hex)
{
string ret(32, '\0');
sha3(bytesConstRef((byte const*)_input.data(), _input.size()), bytesRef((byte*)ret.data(), 32));
return ret;
}
uint8_t buf[32];
sha3(bytesConstRef((byte const*)_input.data(), _input.size()), bytesRef((byte*)&(buf[0]), 32));
std::string ret(64, '\0');
for (unsigned int i = 0; i < 32; i++)
sprintf((char*)(ret.data())+i*2, "%02x", buf[i]);
return ret;
}
void eth::sha3(bytesConstRef _input, bytesRef _output)
{
CryptoPP::SHA3_256 ctx;
ctx.Update((byte*)_input.data(), _input.size());
assert(_output.size() >= 32);
ctx.Final(_output.data());
}
bytes eth::sha3Bytes(bytesConstRef _input)
{
bytes ret(32);
sha3(_input, &ret);
return ret;
}
h256 eth::sha3(bytesConstRef _input)
{
h256 ret;
sha3(_input, bytesRef(&ret[0], 32));
return ret;
}

26
libethereum/FixedHash.h → libethcore/FixedHash.h

@ -186,6 +186,32 @@ inline h160 left160(h256 const& _t)
return ret;
}
// SHA-3 convenience routines.
/// Calculate SHA3-256 hash of the given input and load it into the given output.
void sha3(bytesConstRef _input, bytesRef _output);
/// Calculate SHA3-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data.
std::string sha3(std::string const& _input, bool _isNibbles);
/// Calculate SHA3-256 hash of the given input, returning as a byte array.
bytes sha3Bytes(bytesConstRef _input);
/// Calculate SHA3-256 hash of the given input (presented as a binary string), returning as a byte array.
inline bytes sha3Bytes(std::string const& _input) { return sha3Bytes((std::string*)&_input); }
/// Calculate SHA3-256 hash of the given input, returning as a byte array.
inline bytes sha3Bytes(bytes const& _input) { return sha3Bytes((bytes*)&_input); }
/// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
h256 sha3(bytesConstRef _input);
/// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
inline h256 sha3(bytes const& _input) { return sha3(bytesConstRef((bytes*)&_input)); }
/// Calculate SHA3-256 hash of the given input (presented as a binary-filled string), returning as a 256-bit hash.
inline h256 sha3(std::string const& _input) { return sha3(bytesConstRef(_input)); }
}
namespace std

0
libethereum/Log.cpp → libethcore/Log.cpp

0
libethereum/Log.h → libethcore/Log.h

0
libethereum/RLP.cpp → libethcore/RLP.cpp

1
libethereum/RLP.h → libethcore/RLP.h

@ -31,6 +31,7 @@
#include "vector_ref.h"
#include "Common.h"
#include "Exceptions.h"
#include "FixedHash.h"
namespace eth
{

0
libethereum/TrieCommon.cpp → libethcore/TrieCommon.cpp

0
libethereum/TrieCommon.h → libethcore/TrieCommon.h

0
libethereum/TrieDB.cpp → libethcore/TrieDB.cpp

3
libethereum/TrieDB.h → libethcore/TrieDB.h

@ -23,8 +23,7 @@
#include <map>
#include <memory>
#include "Exceptions.h"
#include "CommonEth.h"
#include "Common.h"
#include "Log.h"
#include "TrieCommon.h"
namespace ldb = leveldb;

2
libethereum/UPnP.cpp → libethcore/UPnP.cpp

@ -25,9 +25,9 @@
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include "Exceptions.h"
#include "Common.h"
#include "Log.h"
#include "Exceptions.h"
#include "UPnP.h"
using namespace std;
using namespace eth;

0
libethereum/UPnP.h → libethcore/UPnP.h

0
libethereum/vector_ref.h → libethcore/vector_ref.h

4
libethereum/AddressState.h

@ -21,8 +21,8 @@
#pragma once
#include "Common.h"
#include "RLP.h"
#include <libethcore/Common.h>
#include <libethcore/RLP.h>
namespace eth
{

6
libethereum/BlockChain.cpp

@ -22,13 +22,13 @@
#include "BlockChain.h"
#include <boost/filesystem.hpp>
#include "Common.h"
#include "RLP.h"
#include <libethcore/Common.h>
#include <libethcore/RLP.h>
#include <libethcore/FileSystem.h>
#include "Exceptions.h"
#include "Dagger.h"
#include "BlockInfo.h"
#include "State.h"
#include "FileSystem.h"
#include "Defaults.h"
using namespace std;
using namespace eth;

2
libethereum/BlockChain.h

@ -22,8 +22,8 @@
#pragma once
#include <mutex>
#include <libethcore/Log.h>
#include "CommonEth.h"
#include "Log.h"
#include "AddressState.h"
namespace ldb = leveldb;

4
libethereum/BlockInfo.cpp

@ -19,10 +19,10 @@
* @date 2014
*/
#include "Common.h"
#include <libethcore/Common.h>
#include <libethcore/RLP.h>
#include "Dagger.h"
#include "Exceptions.h"
#include "RLP.h"
#include "State.h"
#include "BlockInfo.h"
using namespace std;

2
libethereum/BlockInfo.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
#include "Transaction.h"
namespace eth

73
libethereum/CMakeLists.txt

@ -4,59 +4,62 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB")
aux_source_directory(. SRC_LIST)
set(EXECUTABLE ethereum)
if(APPLE)
# set(CMAKE_INSTALL_PREFIX ../lib)
add_library(ethereum SHARED ${SRC_LIST})
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
else()
add_library(ethereum ${SRC_LIST})
add_library(${EXECUTABLE} ${SRC_LIST})
endif()
if (UNIX)
FIND_PACKAGE(Boost 1.53 REQUIRED COMPONENTS thread date_time system filesystem program_options signals serialization chrono unit_test_framework locale)
endif()
file(GLOB HEADERS "*.h")
include_directories(../secp256k1)
include_directories(..)
target_link_libraries(ethereum secp256k1)
target_link_libraries(ethereum miniupnpc)
target_link_libraries(ethereum leveldb)
target_link_libraries(ethereum gmp)
target_link_libraries(${EXECUTABLE} ethcore)
target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} miniupnpc)
target_link_libraries(${EXECUTABLE} leveldb)
target_link_libraries(${EXECUTABLE} gmp)
if(${TARGET_PLATFORM} STREQUAL "w64")
include_directories(/usr/x86_64-w64-mingw32/include/cryptopp)
target_link_libraries(ethereum cryptopp)
target_link_libraries(ethereum boost_system-mt-s)
target_link_libraries(ethereum boost_filesystem-mt-s)
target_link_libraries(ethereum boost_thread_win32-mt-s)
target_link_libraries(ethereum iphlpapi)
target_link_libraries(ethereum ws2_32)
target_link_libraries(ethereum mswsock)
target_link_libraries(ethereum shlwapi)
target_link_libraries(${EXECUTABLE} cryptopp)
target_link_libraries(${EXECUTABLE} boost_system-mt-s)
target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s)
target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s)
target_link_libraries(${EXECUTABLE} iphlpapi)
target_link_libraries(${EXECUTABLE} ws2_32)
target_link_libraries(${EXECUTABLE} mswsock)
target_link_libraries(${EXECUTABLE} shlwapi)
elseif (APPLE)
# Latest mavericks boost libraries only come with -mt
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum boost_system-mt)
target_link_libraries(ethereum boost_filesystem-mt)
target_link_libraries(ethereum boost_thread-mt)
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} boost_system-mt)
target_link_libraries(${EXECUTABLE} boost_filesystem-mt)
target_link_libraries(${EXECUTABLE} boost_thread-mt)
find_package(Threads REQUIRED)
target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
elseif (UNIX)
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum ${Boost_SYSTEM_LIBRARY})
target_link_libraries(ethereum ${Boost_FILESYSTEM_LIBRARY})
target_link_libraries(ethereum ${Boost_THREAD_LIBRARY})
target_link_libraries(ethereum ${Boost_DATE_TIME_LIBRARY})
target_link_libraries(ethereum leveldb)
# target_link_libraries(ethereum snappy)
target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${Boost_SYSTEM_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_FILESYSTEM_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_THREAD_LIBRARY})
target_link_libraries(${EXECUTABLE} ${Boost_DATE_TIME_LIBRARY})
target_link_libraries(${EXECUTABLE} leveldb)
# target_link_libraries(${EXECUTABLE} snappy)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
else ()
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum boost_system)
target_link_libraries(ethereum boost_filesystem)
target_link_libraries(ethereum boost_thread)
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
target_link_libraries(${EXECUTABLE} boost_system)
target_link_libraries(${EXECUTABLE} boost_filesystem)
target_link_libraries(${EXECUTABLE} boost_thread)
find_package(Threads REQUIRED)
target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@ -66,6 +69,6 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message("Installation path: ${CMAKE_INSTALL_PREFIX}")
install( TARGETS ethereum ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/ethereum )
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

2
libethereum/Client.cpp

@ -24,7 +24,7 @@
#include <chrono>
#include <thread>
#include <boost/filesystem.hpp>
#include "Common.h"
#include <libethcore/Common.h>
#include "Defaults.h"
#include "PeerServer.h"
using namespace std;

2
libethereum/Client.h

@ -24,7 +24,7 @@
#include <thread>
#include <mutex>
#include <atomic>
#include "Common.h"
#include <libethcore/Common.h>
#include "BlockChain.h"
#include "TransactionQueue.h"
#include "State.h"

43
libethereum/CommonEth.cpp

@ -20,9 +20,9 @@
*/
#include "CommonEth.h"
#include "CryptoHeaders.h"
#include "Exceptions.h"
#include <random>
#include <secp256k1/secp256k1.h>
#include "Exceptions.h"
using namespace std;
using namespace eth;
@ -148,42 +148,3 @@ KeyPair::KeyPair(h256 _sec):
cout << "ADR: " << m_address << endl;
#endif
}
std::string eth::sha3(std::string const& _input, bool _hex)
{
if (!_hex)
{
string ret(32, '\0');
sha3(bytesConstRef((byte const*)_input.data(), _input.size()), bytesRef((byte*)ret.data(), 32));
return ret;
}
uint8_t buf[32];
sha3(bytesConstRef((byte const*)_input.data(), _input.size()), bytesRef((byte*)&(buf[0]), 32));
std::string ret(64, '\0');
for (unsigned int i = 0; i < 32; i++)
sprintf((char*)(ret.data())+i*2, "%02x", buf[i]);
return ret;
}
void eth::sha3(bytesConstRef _input, bytesRef _output)
{
CryptoPP::SHA3_256 ctx;
ctx.Update((byte*)_input.data(), _input.size());
assert(_output.size() >= 32);
ctx.Final(_output.data());
}
bytes eth::sha3Bytes(bytesConstRef _input)
{
bytes ret(32);
sha3(_input, &ret);
return ret;
}
h256 eth::sha3(bytesConstRef _input)
{
h256 ret;
sha3(_input, bytesRef(&ret[0], 32));
return ret;
}

31
libethereum/CommonEth.h

@ -23,8 +23,8 @@
#pragma once
#include "Common.h"
#include "FixedHash.h"
#include <libethcore/Common.h>
#include <libethcore/FixedHash.h>
namespace eth
{
@ -110,31 +110,4 @@ private:
Address m_address;
};
// SHA-3 convenience routines.
/// Calculate SHA3-256 hash of the given input and load it into the given output.
void sha3(bytesConstRef _input, bytesRef _output);
/// Calculate SHA3-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data.
std::string sha3(std::string const& _input, bool _isNibbles);
/// Calculate SHA3-256 hash of the given input, returning as a byte array.
bytes sha3Bytes(bytesConstRef _input);
/// Calculate SHA3-256 hash of the given input (presented as a binary string), returning as a byte array.
inline bytes sha3Bytes(std::string const& _input) { return sha3Bytes((std::string*)&_input); }
/// Calculate SHA3-256 hash of the given input, returning as a byte array.
inline bytes sha3Bytes(bytes const& _input) { return sha3Bytes((bytes*)&_input); }
/// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
h256 sha3(bytesConstRef _input);
/// Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
inline h256 sha3(bytes const& _input) { return sha3(bytesConstRef((bytes*)&_input)); }
/// Calculate SHA3-256 hash of the given input (presented as a binary-filled string), returning as a 256-bit hash.
inline h256 sha3(std::string const& _input) { return sha3(bytesConstRef(_input)); }
}

4
libethereum/Dagger.cpp

@ -23,8 +23,8 @@
#include <chrono>
#include <array>
#include <random>
#include "CryptoHeaders.h"
#include "Common.h"
#include <libethcore/CryptoHeaders.h>
#include <libethcore/Common.h>
#include "Dagger.h"
using namespace std;
using namespace std::chrono;

1
libethereum/Dagger.h

@ -23,7 +23,6 @@
#pragma once
#include "FixedHash.h"
#include "CommonEth.h"
#define FAKE_DAGGER 1

2
libethereum/Defaults.cpp

@ -21,7 +21,7 @@
#include "Defaults.h"
#include "FileSystem.h"
#include <libethcore/FileSystem.h>
using namespace std;
using namespace eth;

2
libethereum/Defaults.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
namespace eth
{

24
libethereum/Exceptions.h

@ -1,27 +1,10 @@
#pragma once
#include <exception>
#include "CommonIO.h"
#include "CommonData.h"
#include "FixedHash.h"
#include <libethcore/Exceptions.h>
namespace eth
{
class Exception: public std::exception
{
public:
virtual std::string description() const { return typeid(*this).name(); }
virtual char const* what() const noexcept { return typeid(*this).name(); }
};
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 {};
@ -30,6 +13,8 @@ class OutOfGas: public VMException {};
class StackTooSmall: public VMException { public: StackTooSmall(u256 _req, u256 _got): req(_req), got(_got) {} u256 req; u256 got; };
class OperandOutOfRange: public VMException { public: OperandOutOfRange(u256 _min, u256 _max, u256 _got): mn(_min), mx(_max), got(_got) {} u256 mn; u256 mx; u256 got; };
class NotEnoughCash: public Exception {};
class GasPriceTooLow: public Exception {};
class NoSuchContract: public Exception {};
class ContractAddressCollision: public Exception {};
@ -49,8 +34,5 @@ class InvalidNonce: public Exception { public: InvalidNonce(u256 _required = 0,
class InvalidBlockNonce: public Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual std::string description() const { return "Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"; } };
class InvalidParentHash: public Exception {};
class InvalidContractAddress: public Exception {};
class NoNetworking: public Exception {};
class NoUPnPDevice: public Exception {};
class RootNotFound: public Exception {};
}

2
libethereum/ExtVMFace.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
#include "FeeStructure.h"
#include "BlockInfo.h"

2
libethereum/FeeStructure.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
namespace eth
{

25
libethereum/FixedHash.cpp

@ -1,25 +0,0 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file FixedHash.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "FixedHash.h"
using namespace std;
using namespace eth;

2
libethereum/Instruction.cpp

@ -22,8 +22,8 @@
#include "Instruction.h"
#include <boost/algorithm/string.hpp>
#include <libethcore/Log.h>
#include "CommonEth.h"
#include "Log.h"
using namespace std;
using namespace eth;

2
libethereum/Instruction.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
namespace eth
{

4
libethereum/PeerNetwork.h

@ -27,8 +27,8 @@
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <chrono>
#include "Common.h"
#include "Log.h"
#include <libethcore/Common.h>
#include <libethcore/Log.h>
namespace ba = boost::asio;
namespace bi = boost::asio::ip;

4
libethereum/PeerServer.cpp

@ -34,12 +34,12 @@
#include <set>
#include <chrono>
#include <thread>
#include <libethcore/Common.h>
#include <libethcore/UPnP.h>
#include "Exceptions.h"
#include "Common.h"
#include "BlockChain.h"
#include "BlockInfo.h"
#include "TransactionQueue.h"
#include "UPnP.h"
#include "PeerSession.h"
using namespace std;
using namespace eth;

2
libethereum/PeerSession.cpp

@ -22,8 +22,8 @@
#include "PeerSession.h"
#include <chrono>
#include <libethcore/Common.h>
#include "Exceptions.h"
#include "Common.h"
#include "BlockChain.h"
#include "BlockInfo.h"
#include "PeerServer.h"

2
libethereum/PeerSession.h

@ -25,7 +25,7 @@
#include <set>
#include <memory>
#include <utility>
#include "RLP.h"
#include <libethcore/RLP.h>
#include "CommonEth.h"
#include "PeerNetwork.h"

2
libethereum/State.cpp

@ -21,7 +21,7 @@
#include "State.h"
#include <secp256k1.h>
#include <secp256k1/secp256k1.h>
#include <boost/filesystem.hpp>
#include <time.h>
#include <random>

6
libethereum/State.h

@ -24,14 +24,14 @@
#include <array>
#include <map>
#include <unordered_map>
#include "Common.h"
#include "RLP.h"
#include <libethcore/Common.h>
#include <libethcore/RLP.h>
#include <libethcore/TrieDB.h>
#include "TransactionQueue.h"
#include "Exceptions.h"
#include "BlockInfo.h"
#include "AddressState.h"
#include "Transaction.h"
#include "TrieDB.h"
#include "FeeStructure.h"
#include "Dagger.h"
#include "ExtVMFace.h"

6
libethereum/Transaction.cpp

@ -19,11 +19,11 @@
* @date 2014
*/
#include <secp256k1.h>
#include "vector_ref.h"
#include <secp256k1/secp256k1.h>
#include <libethcore/vector_ref.h>
#include <libethcore/Log.h>
#include "Exceptions.h"
#include "Transaction.h"
#include "Log.h"
using namespace std;
using namespace eth;

2
libethereum/Transaction.h

@ -21,8 +21,8 @@
#pragma once
#include <libethcore/RLP.h>
#include "CommonEth.h"
#include "RLP.h"
namespace eth
{

6
libethereum/TransactionQueue.cpp

@ -19,9 +19,11 @@
* @date 2014
*/
#include "Log.h"
#include "Transaction.h"
#include "TransactionQueue.h"
#include <libethcore/Log.h>
#include "Exceptions.h"
#include "Transaction.h"
using namespace std;
using namespace eth;

2
libethereum/TransactionQueue.h

@ -21,7 +21,7 @@
#pragma once
#include "Common.h"
#include <libethcore/Common.h>
#include "Transaction.h"
namespace eth

2
libqethereum/QEthereum.cpp

@ -1,9 +1,9 @@
#include <QtQml/QtQml>
#include <QtCore/QtCore>
#include <libethcore/FileSystem.h>
#include <libethereum/Dagger.h>
#include <libethereum/Client.h>
#include <libethereum/Instruction.h>
#include <libethereum/FileSystem.h>
#include <libethereum/PeerServer.h>
#include "QEthereum.h"
using namespace std;

2
libqethereum/QEthereum.h

@ -2,7 +2,7 @@
#include <QtCore/QAbstractListModel>
#include <libethereum/CommonEth.h>
#include <libethereum/CommonIO.h>
#include <libethcore/CommonIO.h>
namespace eth {
class Client;

3
neth/CMakeLists.txt

@ -2,7 +2,8 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
include_directories(../libethereum)
include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
add_executable(neth ${SRC_LIST})

14
neth/main.cpp

@ -30,13 +30,13 @@
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim_all.hpp>
#include "Defaults.h"
#include "Client.h"
#include "PeerNetwork.h"
#include "BlockChain.h"
#include "State.h"
#include "FileSystem.h"
#include "Instruction.h"
#include <libethcore/FileSystem.h>
#include <libethereum/Defaults.h>
#include <libethereum/Client.h>
#include <libethereum/PeerNetwork.h>
#include <libethereum/BlockChain.h>
#include <libethereum/State.h>
#include <libethereum/Instruction.h>
#include "BuildInfo.h"
using namespace std;
using namespace eth;

4
test/CMakeLists.txt

@ -2,8 +2,8 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
include_directories(../secp256k1)
include_directories(../libethereum)
include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
add_executable(testeth ${SRC_LIST})

4
test/MemTrie.cpp

@ -21,8 +21,8 @@
#include "MemTrie.h"
#include <CommonEth.h>
#include <TrieCommon.h>
#include <libethcore/TrieCommon.h>
#include <libethereum/CommonEth.h>
using namespace std;
using namespace eth;

4
test/MemTrie.h

@ -21,8 +21,8 @@
#pragma once
#include <Common.h>
#include <FixedHash.h>
#include <libethcore/Common.h>
#include <libethcore/FixedHash.h>
namespace eth
{

2
test/TestHelper.cpp

@ -21,7 +21,7 @@
#include <thread>
#include <chrono>
#include <Client.h>
#include <libethereum/Client.h>
#include "TestHelper.h"
namespace eth

4
test/TrieHash.cpp

@ -21,8 +21,8 @@
#include "TrieHash.h"
#include <CommonEth.h>
#include <TrieCommon.h>
#include <libethcore/TrieCommon.h>
#include <libethereum/CommonEth.h>
using namespace std;
using namespace eth;

4
test/TrieHash.h

@ -21,8 +21,8 @@
#pragma once
#include <Common.h>
#include <FixedHash.h>
#include <libethcore/Common.h>
#include <libethcore/FixedHash.h>
namespace eth
{

10
test/crypto.cpp

@ -21,11 +21,11 @@
*/
#include <random>
#include <secp256k1.h>
#include <Common.h>
#include <RLP.h>
#include <Log.h>
#include <Transaction.h>
#include <secp256k1/secp256k1.h>
#include <libethcore/Common.h>
#include <libethcore/RLP.h>
#include <libethcore/Log.h>
#include <libethereum/Transaction.h>
#include <boost/test/unit_test.hpp>
using namespace std;

4
test/dagger.cpp

@ -21,8 +21,8 @@
*/
#include <chrono>
#include "Log.h"
#include "Dagger.h"
#include <libethcore/Log.h>
#include <libethereum/Dagger.h>
using namespace std;
using namespace std::chrono;
using namespace eth;

6
test/fork.cpp

@ -22,9 +22,9 @@
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <Client.h>
#include <BlockChain.h>
#include <PeerServer.h>
#include <libethereum/Client.h>
#include <libethereum/BlockChain.h>
#include <libethereum/PeerServer.h>
#include "TestHelper.h"
using namespace std;
using namespace eth;

4
test/hexPrefix.cpp

@ -22,8 +22,8 @@
#include <fstream>
#include "JsonSpiritHeaders.h"
#include "TrieCommon.h"
#include "Log.h"
#include <libethcore/TrieCommon.h>
#include <libethcore/Log.h>
#include <boost/test/unit_test.hpp>
using namespace std;

2
test/main.cpp

@ -33,7 +33,7 @@ int vmTest();
int hexPrefixTest();
int peerTest(int argc, char** argv);
#include <BlockInfo.h>
#include <libethereum/BlockInfo.h>
using namespace eth;
BOOST_AUTO_TEST_CASE(basic_tests)

6
test/network.cpp

@ -22,9 +22,9 @@
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <Client.h>
#include <BlockChain.h>
#include <PeerServer.h>
#include <libethereum/Client.h>
#include <libethereum/BlockChain.h>
#include <libethereum/PeerServer.h>
#include "TestHelper.h"
using namespace std;
using namespace eth;

4
test/peer.cpp

@ -23,8 +23,8 @@
#include <chrono>
#include <thread>
#include <boost/filesystem/operations.hpp>
#include <BlockChain.h>
#include <PeerServer.h>
#include <libethereum/BlockChain.h>
#include <libethereum/PeerServer.h>
using namespace std;
using namespace eth;
using boost::asio::ip::tcp;

6
test/rlp.cpp

@ -23,9 +23,9 @@
#include <fstream>
#include <sstream>
#include "JsonSpiritHeaders.h"
#include <Log.h>
#include <RLP.h>
#include <Common.h>
#include <libethcore/Log.h>
#include <libethcore/RLP.h>
#include <libethcore/Common.h>
#include <boost/test/unit_test.hpp>
#include <algorithm>

8
test/state.cpp

@ -21,10 +21,10 @@
*/
#include <boost/filesystem/operations.hpp>
#include <secp256k1.h>
#include <BlockChain.h>
#include <State.h>
#include <Defaults.h>
#include <secp256k1/secp256k1.h>
#include <libethereum/BlockChain.h>
#include <libethereum/State.h>
#include <libethereum/Defaults.h>
using namespace std;
using namespace eth;

2
test/trie.cpp

@ -23,7 +23,7 @@
#include <fstream>
#include <random>
#include "JsonSpiritHeaders.h"
#include <TrieDB.h>
#include <libethcore/TrieDB.h>
#include "TrieHash.h"
#include "MemTrie.h"
#include <boost/test/unit_test.hpp>

6
test/txTest.cpp

@ -22,9 +22,9 @@
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <Client.h>
#include <BlockChain.h>
#include <PeerServer.h>
#include <libethereum/Client.h>
#include <libethereum/BlockChain.h>
#include <libethereum/PeerServer.h>
#include "TestHelper.h"
using namespace std;
using namespace eth;

10
test/vm.cpp

@ -21,11 +21,11 @@
*/
#include <fstream>
#include <ExtVMFace.h>
#include <Transaction.h>
#include <VM.h>
#include <Log.h>
#include <Instruction.h>
#include <libethcore/Log.h>
#include <libethereum/ExtVMFace.h>
#include <libethereum/Transaction.h>
#include <libethereum/VM.h>
#include <libethereum/Instruction.h>
#include "JsonSpiritHeaders.h"
#include <boost/test/unit_test.hpp>

1
walleth/CMakeLists.txt

@ -9,6 +9,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST)
include_directories(..)
link_directories(../libethcore)
link_directories(../libethereum)
link_directories(../libqethereum)

2
walleth/MainWin.cpp

@ -7,10 +7,10 @@
#include <QtWidgets/QInputDialog>
#include <QtGui/QClipboard>
#include <QtCore/QtCore>
#include <libethcore/FileSystem.h>
#include <libethereum/Dagger.h>
#include <libethereum/Client.h>
#include <libethereum/Instruction.h>
#include <libethereum/FileSystem.h>
#include <libethereum/PeerServer.h>
#include "BuildInfo.h"
#include "MainWin.h"

Loading…
Cancel
Save