diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c6ec18cc..e623c7319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,7 +353,7 @@ if (NOT LANGUAGES) add_subdirectory(exp) endif () if(NOT ("${TARGET_PLATFORM}" STREQUAL "w64")) - #add_subdirectory(neth) // resurect once moved over to WebThree API. + add_subdirectory(neth) endif () if(QTQML) add_definitions(-DETH_QTQML) diff --git a/neth/CMakeLists.txt b/neth/CMakeLists.txt index 3e8dab70d..2b3f92947 100644 --- a/neth/CMakeLists.txt +++ b/neth/CMakeLists.txt @@ -11,6 +11,7 @@ set(EXECUTABLE neth) add_executable(${EXECUTABLE} ${SRC_LIST}) +target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethereum) target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} gmp) diff --git a/neth/main.cpp b/neth/main.cpp index e492d1a3c..d9818c72f 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -39,6 +39,7 @@ #include #include #endif +#include #include "BuildInfo.h" #undef KEY_EVENT // from windows.h @@ -413,7 +414,9 @@ int main(int argc, char** argv) if (!clientName.empty()) clientName += "/"; - Client c("NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), coinbase, dbPath); + WebThreeDirect web3("NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), dbPath); + // mode doesn't work anymore: see eth for how that should be structured. + Client& c = *web3.ethereum(); c.setForceMining(true); @@ -479,7 +482,12 @@ int main(int argc, char** argv) wmove(mainwin, 1, 4); if (!remoteHost.empty()) - c.startNetwork(listenPort, remoteHost, remotePort, mode, peers, publicIP, upnp); + { + web3.setIdealPeerCount(peers); + web3.setNetworkPreferences(NetworkPreferences(listenPort, publicIP, upnp)); + web3.startNetwork(); + web3.connect(remoteHost, remotePort); + } if (mining) c.startMining(); @@ -487,7 +495,7 @@ int main(int argc, char** argv) auto_ptr jsonrpcServer; if (jsonrpc > -1) { - jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c)); + jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), web3)); jsonrpcServer->setKeys({us}); jsonrpcServer->StartListening(); } @@ -528,18 +536,19 @@ int main(int argc, char** argv) { unsigned port; iss >> port; - c.startNetwork((short)port); + web3.setNetworkPreferences(NetworkPreferences((short)port, publicIP, upnp)); + web3.startNetwork(); } else if (cmd == "connect") { string addr; unsigned port; iss >> addr >> port; - c.connect(addr, (short)port); + web3.connect(addr, (short)port); } else if (cmd == "netstop") { - c.stopNetwork(); + web3.stopNetwork(); } else if (cmd == "minestart") { @@ -560,7 +569,7 @@ int main(int argc, char** argv) { if (jsonrpc < 0) jsonrpc = 8080; - jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c)); + jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), web3)); jsonrpcServer->setKeys({us}); jsonrpcServer->StartListening(); } @@ -589,7 +598,7 @@ int main(int argc, char** argv) } else if (cmd == "peers") { - for (auto it: c.peers()) + for (auto it: web3.peers()) cout << it.host << ":" << it.port << ", " << it.clientVersion << ", " << std::chrono::duration_cast(it.lastPing).count() << "ms" << endl; @@ -925,7 +934,7 @@ int main(int argc, char** argv) // Peers y = 1; - for (PeerInfo const& i: c.peers()) + for (PeerInfo const& i: web3.peers()) { auto s = boost::format("%1% ms - %2%:%3% - %4%") % toString(chrono::duration_cast(i.lastPing).count()) % @@ -971,7 +980,7 @@ int main(int argc, char** argv) // Peers mvwprintw(peerswin, 0, x, "Peers: "); - mvwprintw(peerswin, 0, 9, toString(c.peers().size()).c_str()); + mvwprintw(peerswin, 0, 9, toString(web3.peers().size()).c_str()); // Mining flag if (c.isMining())