Browse Source

Fix neth. I'm such a soft touch.

cl-refactor
Gav Wood 10 years ago
parent
commit
70d9acac70
  1. 2
      CMakeLists.txt
  2. 1
      neth/CMakeLists.txt
  3. 29
      neth/main.cpp

2
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)

1
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)

29
neth/main.cpp

@ -39,6 +39,7 @@
#include <eth/CommonJS.h>
#include <eth/CommonJS.cpp>
#endif
#include <libwebthree/WebThree.h>
#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<EthStubServer> jsonrpcServer;
if (jsonrpc > -1)
{
jsonrpcServer = auto_ptr<EthStubServer>(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c));
jsonrpcServer = auto_ptr<EthStubServer>(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<EthStubServer>(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c));
jsonrpcServer = auto_ptr<EthStubServer>(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<std::chrono::milliseconds>(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<chrono::milliseconds>(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())

Loading…
Cancel
Save