Browse Source

Merge branch 'master' of github.com:ethereum/cpp-ethereum

Conflicts:
	CMakeLists.txt
	alephzero/alephzero.pro
cl-refactor
Gav Wood 11 years ago
parent
commit
b128638c7c
  1. 95
      CMakeLists.txt
  2. 10
      alephzero/alephzero.pro
  3. 21
      libethereum/PeerNetwork.cpp

95
CMakeLists.txt

@ -23,63 +23,52 @@ else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.") message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif () endif ()
# Override the cryptopp search until we can get the qmake stuff sorted. # Look for available Crypto++ version and if it is >= 5.6.2
#set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE) find_path(ID cryptlib.h
#set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE) /usr/include/cryptopp
/usr/include/crypto++
/usr/local/include/cryptopp
/usr/local/include/crypto++
/opt/local/include/cryptopp
/opt/local/include/crypto++
)
find_library(LS NAMES cryptoppeth cryptopp
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
)
set(CRYPTOPP_INCLUDE_DIR CACHE FILEPATH "" FORCE) if(ID AND LS)
set(CRYPTOPP_LIBRARIES CACHE FILEPATH "" FORCE) set(CRYPTOPP_FOUND TRUE)
message(STATUS "Found Crypto++: ${ID}, ${LS}")
set(_CRYPTOPP_VERSION_HEADER ${ID}/config.h)
if(EXISTS ${_CRYPTOPP_VERSION_HEADER})
file(STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION ${_CRYPTOPP_VERSION})
if(${_CRYPTOPP_VERSION} LESS 562)
message(STATUS "System Crypto++ version found is smaller than 5.6.2.")
else()
set(CRYPTOPP_INCLUDE_DIR ${ID} CACHE FILEPATH "" FORCE)
set(CRYPTOPP_LIBRARIES ${LS} CACHE FILEPATH "" FORCE)
set(CRYPTOPP_FOUND TRUE)
message(STATUS "System Crypto++ found and version greater or equal to 5.6.2")
endif()
endif()
endif()
# Look for availabe Crypto++ version and if it is >= 5.6.2 if(NOT CRYPTOPP_FOUND)
#if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARIES) message(STATUS "System Crypto++ not found, broken or too old. We use ../cryptopp562")
# set(CRYPTOPP_FOUND TRUE) set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE)
# message(STATUS "Found Crypto++: ${CRYPTOPP_INCLUDE_DIR}, ${CRYPTOPP_LIBRARIES}") set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE)
#else() endif()
find_path(ID cryptlib.h
/usr/include/cryptopp
/usr/include/crypto++
/usr/local/include/cryptopp
/usr/local/include/crypto++
/opt/local/include/cryptopp
/opt/local/include/crypto++
)
find_library(LS NAMES cryptoppeth cryptopp
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
)
if(ID AND LS) # Not really worth caching. We want to reevaluate anyway.
set(CRYPTOPP_FOUND TRUE) mark_as_advanced(CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARIES)
message(STATUS "Found Crypto++: ${ID}, ${LS}")
set(_CRYPTOPP_VERSION_HEADER ${ID}/config.h)
if(EXISTS ${_CRYPTOPP_VERSION_HEADER})
file(STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION ${_CRYPTOPP_VERSION})
if(${_CRYPTOPP_VERSION} LESS 562)
message(STATUS "Crypto++ version found is smaller than 5.6.2. We use ../cryptopp562")
set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE)
set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE)
else()
set(CRYPTOPP_INCLUDE_DIR ${ID} CACHE FILEPATH "" FORCE)
set(CRYPTOPP_LIBRARIES ${LS} CACHE FILEPATH "" FORCE)
message(STATUS "Crypto++ found and version greater or equal to 5.6.2")
endif()
endif()
else()
set(CRYPTOPP_FOUND TRUE) # Ugly
message(STATUS "Crypto++ not found. We use ../cryptopp562")
set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE)
set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE)
endif()
mark_as_advanced(CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARIES)
#endif()
if(CRYPTOPP_FOUND) # Always "found", given last block.
include_directories(${CRYPTOPP_INCLUDE_DIR}) include_directories(${CRYPTOPP_INCLUDE_DIR})
link_directories(${CRYPTOPP_LIBRARIES}) link_directories(${CRYPTOPP_LIBRARIES})
endif()
add_subdirectory(secp256k1) add_subdirectory(secp256k1)
add_subdirectory(libethereum) add_subdirectory(libethereum)

10
alephzero/alephzero.pro

@ -14,10 +14,18 @@ CONFIG(debug, debug|release): DEFINES += ETH_DEBUG
QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11
#CONFIG += local_cryptopp
local_cryptopp {
QMAKE_LIBDIR += ../../cryptopp562
INCLUDE_PATH += ../libethereum
LIBS += -lcryptoppeth
}
INCLUDEPATH += ../../cpp-ethereum INCLUDEPATH += ../../cpp-ethereum
QMAKE_LIBDIR += ../../cpp-ethereum-build/libethereum QMAKE_LIBDIR += ../../cpp-ethereum-build/libethereum
CONFIG(debug, debug|release): LIBS += -Wl,-rpath,../../cpp-ethereum-build/libethereum CONFIG(debug, debug|release): LIBS += -Wl,-rpath,../../cpp-ethereum-build/libethereum
LIBS += -lethereum -lcryptoppeth -lminiupnpc -lsecp256k1 -lleveldb -lgmp -lboost_filesystem -lboost_system LIBS += -lethereum -lminiupnpc -lleveldb -lgmp -lboost_filesystem -lboost_system
SOURCES += main.cpp \ SOURCES += main.cpp \
MainWin.cpp MainWin.cpp

21
libethereum/PeerNetwork.cpp

@ -36,6 +36,17 @@ static const eth::uint c_maxHashes = 256; ///< Maximum number of hashes GetChai
static const eth::uint c_maxBlocks = 128; ///< Maximum number of blocks Blocks will ever send. BUG: if this gets too big (e.g. 2048) stuff starts going wrong. static const eth::uint c_maxBlocks = 128; ///< Maximum number of blocks Blocks will ever send. BUG: if this gets too big (e.g. 2048) stuff starts going wrong.
static const eth::uint c_maxBlocksAsk = 2048; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain). static const eth::uint c_maxBlocksAsk = 2048; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain).
// Addresses we will skip during network interface discovery
// Use a vector as the list is small
// Why this and not names?
// Under MacOSX loopback (127.0.0.1) can be named lo0 and br0 are bridges (0.0.0.0)
static const vector<bi::address> c_rejectAddresses = {
{bi::address_v4::from_string("127.0.0.1")},
{bi::address_v6::from_string("::1")},
{bi::address_v4::from_string("0.0.0.0")},
{bi::address_v6::from_string("::")}
};
PeerSession::PeerSession(PeerServer* _s, bi::tcp::socket _socket, uint _rNId): PeerSession::PeerSession(PeerServer* _s, bi::tcp::socket _socket, uint _rNId):
m_server(_s), m_server(_s),
m_socket(std::move(_socket)), m_socket(std::move(_socket)),
@ -781,11 +792,13 @@ void PeerServer::populateAddresses()
continue; continue;
auto it = r.resolve({host, "30303"}); auto it = r.resolve({host, "30303"});
bi::tcp::endpoint ep = it->endpoint(); bi::tcp::endpoint ep = it->endpoint();
m_addresses.push_back(ep.address().to_v4()); bi::address ad = ep.address();
if (ifa->ifa_name != string("lo")) m_addresses.push_back(ad.to_v4());
m_peerAddresses.push_back(ep.address().to_v4()); bool isLocal = std::find(c_rejectAddresses.begin(), c_rejectAddresses.end(), ad) != c_rejectAddresses.end();
if (!isLocal)
m_peerAddresses.push_back(ad.to_v4());
if (m_verbosity >= 1) if (m_verbosity >= 1)
cout << "Address: " << host << " = " << m_addresses.back() << (ifa->ifa_name != string("lo") ? " [PEER]" : " [LOCAL]") << endl; cout << "Address: " << host << " = " << m_addresses.back() << (isLocal ? " [LOCAL]" : " [PEER]") << endl;
} }
} }

Loading…
Cancel
Save