Gav Wood
11 years ago
83 changed files with 348 additions and 257 deletions
@ -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,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,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; |
||||
|
} |
@ -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; |
|
Loading…
Reference in new issue