Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix alephzero - support for miniupnpc api 16 - fix test/trie.cxx #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

# Compiler-specific C++11 activation.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
endif()

# Look for available Crypto++ version and if it is >= 5.6.2
find_path(ID cryptlib.h
Expand Down
34 changes: 6 additions & 28 deletions alephzero/alephzero.pro
Original file line number Diff line number Diff line change
@@ -1,39 +1,17 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-01-22T11:47:38
#
#-------------------------------------------------

QT += core gui widgets network


TARGET = alephzero
TEMPLATE = app

CONFIG(debug, debug|release): DEFINES += ETH_DEBUG

QMAKE_CXXFLAGS += -std=c++11

#CONFIG += local_cryptopp

local_cryptopp {
QMAKE_LIBDIR += ../../cryptopp562
INCLUDE_PATH += ../libethereum
LIBS += -lcryptoppeth
}

INCLUDEPATH += ../../cpp-ethereum
QMAKE_LIBDIR += ../../cpp-ethereum-build/libethereum
CONFIG(debug, debug|release): LIBS += -Wl,-rpath,../../cpp-ethereum-build/libethereum
LIBS += -lethereum -lminiupnpc -lleveldb -lgmp -lboost_filesystem -lboost_system

SOURCES += main.cpp \
MainWin.cpp

HEADERS += \
MainWin.h
INCLUDEPATH += ..
QMAKE_LIBDIR += ../build/libethereum ../build/secp256k1
CONFIG(debug, debug|release): LIBS += -Wl,-rpath,../build/libethereum
LIBS += -lethereum -lsecp256k1 -lminiupnpc -lleveldb -lgmp -lboost_filesystem -lboost_system -lcryptopp

SOURCES += main.cpp MainWin.cpp
HEADERS += MainWin.h
FORMS += Main.ui



6 changes: 4 additions & 2 deletions libethereum/PeerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ struct UPnP
printf("TB : init_upnp()\n");
memset(&urls, 0, sizeof(struct UPNPUrls));
memset(&data, 0, sizeof(struct IGDdatas));
devlist = upnpDiscover(2000, NULL/*multicast interface*/, NULL/*minissdpd socket path*/, 0/*sameport*/, 0/*ipv6*/, &upnperror);
devlist = upnpDiscover(2000, NULL/*multicast interface*/, NULL/*minissdpd socket path*/, 0/*sameport*/, 0/*ipv6*/, 2/*ttl*/, &upnperror);
if (devlist)
{
dev = devlist;
Expand All @@ -566,7 +566,9 @@ struct UPnP
printf("UPnP device :\n"
" desc: %s\n st: %s\n",
dev->descURL, dev->st);
#if MINIUPNPC_API_VERSION >= 9
#if MINIUPNPC_API_VERSION >= 16
descXML = (char*)miniwget(dev->descURL, &descXMLsize, 2, 0);
#elif MINIUPNPC_API_VERSION >= 9
descXML = (char*)miniwget(dev->descURL, &descXMLsize, 0);
#else
descXML = (char*)miniwget(dev->descURL, &descXMLsize);
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_policy(SET CMP0015 NEW)

aux_source_directory(. SRC_LIST)

include_directories(../libethereum)
include_directories(../libethereum ../secp256k1)
link_directories(../libethereum)

add_executable(testeth ${SRC_LIST})
Expand Down
10 changes: 5 additions & 5 deletions test/trie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ int trieTest()
cout << t;
cout << m;
cout << t.root() << endl;
cout << hash256({{"test", "test"}}) << endl;
cout << hash256(StringMap{{"test", "test"}}) << endl;

t.insert(string("tesa"), string("testy"));
cout << t;
cout << m;
cout << t.root() << endl;
cout << hash256({{"test", "test"}, {"te", "testy"}}) << endl;
cout << hash256(StringMap{{"test", "test"}, {"te", "testy"}}) << endl;
cout << t.at(string("test")) << endl;
cout << t.at(string("te")) << endl;
cout << t.at(string("t")) << endl;

t.remove(string("te"));
cout << m;
cout << t.root() << endl;
cout << hash256({{"test", "test"}}) << endl;
cout << hash256(StringMap{{"test", "test"}}) << endl;

t.remove(string("test"));
cout << m;
Expand All @@ -72,7 +72,7 @@ int trieTest()
cout << t;
cout << m;
cout << t.root() << endl;
cout << hash256({{"b", "B"}, {"a", "A"}}) << endl;
cout << hash256(StringMap{{"b", "B"}, {"a", "A"}}) << endl;
cout << RLP(rlp256({{"b", "B"}, {"a", "A"}})) << endl;
}
{
Expand All @@ -89,7 +89,7 @@ int trieTest()
cout << RLP(t.rlp()) << endl;
}
{
cout << hex << hash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl;
cout << hex << hash256(StringMap{{"dog", "puppy"}, {"doe", "reindeer"}}) << endl;
MemTrie t;
t.insert("dog", "puppy");
t.insert("doe", "reindeer");
Expand Down