Browse Source

ethrpc -> web3jsonrpc, other issues fixed

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
d76a44f226
  1. 6
      CMakeLists.txt
  2. 2
      alethzero/CMakeLists.txt
  3. 2
      alethzero/MainWin.cpp
  4. 4
      eth/CMakeLists.txt
  5. 22
      eth/main.cpp
  6. 2
      libweb3jsonrpc/CMakeLists.txt
  7. 0
      libweb3jsonrpc/CorsHttpServer.cpp
  8. 0
      libweb3jsonrpc/CorsHttpServer.h
  9. 0
      libweb3jsonrpc/WebThreeStubServer.cpp
  10. 0
      libweb3jsonrpc/WebThreeStubServer.h
  11. 0
      libweb3jsonrpc/abstractwebthreestubserver.h
  12. 0
      libweb3jsonrpc/spec.json
  13. 4
      neth/CMakeLists.txt
  14. 24
      neth/main.cpp
  15. 4
      test/CMakeLists.txt
  16. 4
      test/jsonrpc.cpp
  17. 3
      third/CMakeLists.txt
  18. 2
      third/MainWin.cpp

6
CMakeLists.txt

@ -119,7 +119,9 @@ endif()
add_subdirectory(lllc) add_subdirectory(lllc)
add_subdirectory(solc) add_subdirectory(solc)
add_subdirectory(sc) add_subdirectory(sc)
add_subdirectory(libethrpc) if (JSONRPC_LS OR (NOT HEADLESS))
add_subdirectory(libweb3jsonrpc)
endif()
if (NOT LANGUAGES) if (NOT LANGUAGES)
add_subdirectory(secp256k1) add_subdirectory(secp256k1)
add_subdirectory(libp2p) add_subdirectory(libp2p)
@ -148,7 +150,7 @@ if (NOT LANGUAGES)
if ("${TARGET_PLATFORM}" STREQUAL "w64") if ("${TARGET_PLATFORM}" STREQUAL "w64")
cmake_policy(SET CMP0020 NEW) cmake_policy(SET CMP0020 NEW)
endif () endif ()
add_subdirectory(libqethereum) add_subdirectory(libqethereum)
add_subdirectory(alethzero) add_subdirectory(alethzero)
add_subdirectory(third) add_subdirectory(third)

2
alethzero/CMakeLists.txt

@ -53,7 +53,7 @@ else ()
endif () endif ()
qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets) qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)
target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore ethrpc) target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore web3jsonrpc)
if (APPLE) if (APPLE)
# First have qt5 install plugins and frameworks # First have qt5 install plugins and frameworks

2
alethzero/MainWin.cpp

@ -41,7 +41,7 @@
#include <libethereum/Client.h> #include <libethereum/Client.h>
#include <libethereum/EthereumHost.h> #include <libethereum/EthereumHost.h>
#include <libethereum/DownloadMan.h> #include <libethereum/DownloadMan.h>
#include <libethrpc/WebThreeStubServer.h> #include <libweb3jsonrpc/WebThreeStubServer.h>
#include "DownloadView.h" #include "DownloadView.h"
#include "MiningView.h" #include "MiningView.h"
#include "BuildInfo.h" #include "BuildInfo.h"

4
eth/CMakeLists.txt

@ -19,7 +19,9 @@ if(MINIUPNPC_LS)
endif() endif()
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS}) target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
target_link_libraries(${EXECUTABLE} ethrpc) if(JSONRPC_LS)
target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif()
if(READLINE_LS) if(READLINE_LS)
target_link_libraries(${EXECUTABLE} ${READLINE_LS}) target_link_libraries(${EXECUTABLE} ${READLINE_LS})
endif() endif()

22
eth/main.cpp

@ -27,9 +27,10 @@
#include <signal.h> #include <signal.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim_all.hpp> #include <boost/algorithm/string/trim_all.hpp>
#include <jsonrpc/rpc.h> #if ETH_JSONRPC
#include <libethrpc/CorsHttpServer.h> #include <jsonrpc/connectors/httpserver.h>
#include <libethrpc/WebThreeStubServer.h> #include <libweb3jsonrpc/CorsHttpServer.h>
#endif
#include <libdevcrypto/FileSystem.h> #include <libdevcrypto/FileSystem.h>
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include <libevm/VM.h> #include <libevm/VM.h>
@ -39,6 +40,9 @@
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
#endif #endif
#if ETH_JSONRPC
#include <libweb3jsonrpc/WebThreeStubServer.h>
#endif
#include "BuildInfo.h" #include "BuildInfo.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
@ -104,8 +108,10 @@ void help()
<< " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl << " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl
<< " -h,--help Show this help message and exit." << endl << " -h,--help Show this help message and exit." << endl
<< " -i,--interactive Enter interactive mode (default: non-interactive)." << endl << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl
#if ETH_JSONRPC
<< " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
<< " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl
#endif
<< " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl << " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl
<< " -m,--mining <on/off/number> Enable mining, optionally for a specified number of blocks (Default: off)" << endl << " -m,--mining <on/off/number> Enable mining, optionally for a specified number of blocks (Default: off)" << endl
<< " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl << " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl
@ -179,7 +185,9 @@ int main(int argc, char** argv)
NodeMode mode = NodeMode::Full; NodeMode mode = NodeMode::Full;
unsigned peers = 5; unsigned peers = 5;
bool interactive = false; bool interactive = false;
#if ETH_JSONRPC
int jsonrpc = -1; int jsonrpc = -1;
#endif
string publicIP; string publicIP;
bool bootstrap = false; bool bootstrap = false;
bool upnp = true; bool upnp = true;
@ -264,10 +272,12 @@ int main(int argc, char** argv)
forceMining = true; forceMining = true;
else if (arg == "-i" || arg == "--interactive") else if (arg == "-i" || arg == "--interactive")
interactive = true; interactive = true;
#if ETH_JSONRPC
else if ((arg == "-j" || arg == "--json-rpc")) else if ((arg == "-j" || arg == "--json-rpc"))
jsonrpc = jsonrpc == -1 ? 8080 : jsonrpc; jsonrpc = jsonrpc == -1 ? 8080 : jsonrpc;
else if (arg == "--json-rpc-port" && i + 1 < argc) else if (arg == "--json-rpc-port" && i + 1 < argc)
jsonrpc = atoi(argv[++i]); jsonrpc = atoi(argv[++i]);
#endif
else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
g_logVerbosity = atoi(argv[++i]); g_logVerbosity = atoi(argv[++i]);
else if ((arg == "-x" || arg == "--peers") && i + 1 < argc) else if ((arg == "-x" || arg == "--peers") && i + 1 < argc)
@ -326,12 +336,14 @@ int main(int argc, char** argv)
if (remoteHost.size()) if (remoteHost.size())
web3.connect(remoteHost, remotePort); web3.connect(remoteHost, remotePort);
#if ETH_JSONRPC
auto_ptr<WebThreeStubServer> jsonrpcServer; auto_ptr<WebThreeStubServer> jsonrpcServer;
if (jsonrpc > -1) if (jsonrpc > -1)
{ {
jsonrpcServer = auto_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::CorsHttpServer(jsonrpc), web3, {us})); jsonrpcServer = auto_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::CorsHttpServer(jsonrpc), web3, {us}));
jsonrpcServer->StartListening(); jsonrpcServer->StartListening();
} }
#endif
signal(SIGABRT, &sighandler); signal(SIGABRT, &sighandler);
signal(SIGTERM, &sighandler); signal(SIGTERM, &sighandler);
@ -404,6 +416,7 @@ int main(int argc, char** argv)
iss >> g_logVerbosity; iss >> g_logVerbosity;
cout << "Verbosity: " << g_logVerbosity << endl; cout << "Verbosity: " << g_logVerbosity << endl;
} }
#if ETH_JSONRPC
else if (cmd == "jsonport") else if (cmd == "jsonport")
{ {
if (iss.peek() != -1) if (iss.peek() != -1)
@ -423,6 +436,7 @@ int main(int argc, char** argv)
jsonrpcServer->StopListening(); jsonrpcServer->StopListening();
jsonrpcServer.reset(); jsonrpcServer.reset();
} }
#endif
else if (cmd == "address") else if (cmd == "address")
{ {
cout << "Current address:" << endl; cout << "Current address:" << endl;
@ -755,8 +769,10 @@ int main(int argc, char** argv)
else else
cout << "Unrecognised command. Type 'help' for help in interactive mode." << endl; cout << "Unrecognised command. Type 'help' for help in interactive mode." << endl;
} }
#if ETH_JSONRPC
if (jsonrpcServer.get()) if (jsonrpcServer.get())
jsonrpcServer->StopListening(); jsonrpcServer->StopListening();
#endif
} }
else if (c) else if (c)
{ {

2
libethrpc/CMakeLists.txt → libweb3jsonrpc/CMakeLists.txt

@ -6,7 +6,7 @@ include_directories(..)
link_directories(../libethcore) link_directories(../libethcore)
link_directories(../libwebthree) link_directories(../libwebthree)
set(EXECUTABLE ethrpc) set(EXECUTABLE web3jsonrpc)
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
if(ETH_STATIC) if(ETH_STATIC)

0
libethrpc/CorsHttpServer.cpp → libweb3jsonrpc/CorsHttpServer.cpp

0
libethrpc/CorsHttpServer.h → libweb3jsonrpc/CorsHttpServer.h

0
libethrpc/WebThreeStubServer.cpp → libweb3jsonrpc/WebThreeStubServer.cpp

0
libethrpc/WebThreeStubServer.h → libweb3jsonrpc/WebThreeStubServer.h

0
libethrpc/abstractwebthreestubserver.h → libweb3jsonrpc/abstractwebthreestubserver.h

0
libethrpc/spec.json → libweb3jsonrpc/spec.json

4
neth/CMakeLists.txt

@ -20,7 +20,9 @@ target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS})
endif() endif()
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS}) target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
target_link_libraries(${EXECUTABLE} ethrpc) if(JSONRPC_LS)
target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif()
if ("${TARGET_PLATFORM}" STREQUAL "w64") if ("${TARGET_PLATFORM}" STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")

24
neth/main.cpp

@ -26,13 +26,17 @@
#include <iostream> #include <iostream>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim_all.hpp> #include <boost/algorithm/string/trim_all.hpp>
#if ETH_JSONRPC
#include <jsonrpc/connectors/httpserver.h> #include <jsonrpc/connectors/httpserver.h>
#include <libethrpc/WebThreeStubServer.h> #endif
#include <libethrpc/abstractwebthreestubserver.h>
#include <libdevcore/CommonJS.h>
#include <libdevcrypto/FileSystem.h> #include <libdevcrypto/FileSystem.h>
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include <libethereum/All.h> #include <libethereum/All.h>
#if ETH_JSONRPC
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include <libweb3jsonrpc/abstractwebthreestubserver.h>
#include <libdevcore/CommonJS.h>
#endif
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#include "BuildInfo.h" #include "BuildInfo.h"
@ -69,8 +73,10 @@ void help()
<< " -d,--db-path <path> Load database from path (default: ~/.ethereum " << endl << " -d,--db-path <path> Load database from path (default: ~/.ethereum " << endl
<< " <APPDATA>/Etherum or Library/Application Support/Ethereum)." << endl << " <APPDATA>/Etherum or Library/Application Support/Ethereum)." << endl
<< " -h,--help Show this help message and exit." << endl << " -h,--help Show this help message and exit." << endl
#if ETH_JSONRPC
<< " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
<< " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl
#endif
<< " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl << " -l,--listen <port> Listen on the given port for incoming connected (default: 30303)." << endl
<< " -m,--mining <on/off> Enable mining (default: off)" << endl << " -m,--mining <on/off> Enable mining (default: off)" << endl
<< " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl << " -n,--upnp <on/off> Use upnp for NAT (default: on)." << endl
@ -91,8 +97,10 @@ void interactiveHelp()
<< "Commands:" << endl << "Commands:" << endl
<< " netstart <port> Starts the network sybsystem on a specific port." << endl << " netstart <port> Starts the network sybsystem on a specific port." << endl
<< " netstop Stops the network subsystem." << endl << " netstop Stops the network subsystem." << endl
#if ETH_JSONRPC
<< " jsonstart <port> Starts the JSON-RPC server." << endl << " jsonstart <port> Starts the JSON-RPC server." << endl
<< " jsonstop Stops the JSON-RPC server." << endl << " jsonstop Stops the JSON-RPC server." << endl
#endif
<< " connect <addr> <port> Connects to a specific peer." << endl << " connect <addr> <port> Connects to a specific peer." << endl
<< " minestart Starts mining." << endl << " minestart Starts mining." << endl
<< " minestop Stops mining." << endl << " minestop Stops mining." << endl
@ -296,7 +304,9 @@ int main(int argc, char** argv)
string dbPath; string dbPath;
bool mining = false; bool mining = false;
unsigned peers = 5; unsigned peers = 5;
#if ETH_JSONRPC
int jsonrpc = 8080; int jsonrpc = 8080;
#endif
string publicIP; string publicIP;
bool upnp = true; bool upnp = true;
string clientName; string clientName;
@ -367,10 +377,12 @@ int main(int argc, char** argv)
cerr << "Unknown mining option: " << m << endl; cerr << "Unknown mining option: " << m << endl;
} }
} }
#if ETH_JSONRPC
else if ((arg == "-j" || arg == "--json-rpc")) else if ((arg == "-j" || arg == "--json-rpc"))
jsonrpc = jsonrpc ? jsonrpc : 8080; jsonrpc = jsonrpc ? jsonrpc : 8080;
else if (arg == "--json-rpc-port" && i + 1 < argc) else if (arg == "--json-rpc-port" && i + 1 < argc)
jsonrpc = atoi(argv[++i]); jsonrpc = atoi(argv[++i]);
#endif
else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc) else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
g_logVerbosity = atoi(argv[++i]); g_logVerbosity = atoi(argv[++i]);
else if ((arg == "-x" || arg == "--peers") && i + 1 < argc) else if ((arg == "-x" || arg == "--peers") && i + 1 < argc)
@ -462,12 +474,14 @@ int main(int argc, char** argv)
if (mining) if (mining)
c.startMining(); c.startMining();
#if ETH_JSONRPC
auto_ptr<WebThreeStubServer> jsonrpcServer; auto_ptr<WebThreeStubServer> jsonrpcServer;
if (jsonrpc > -1) if (jsonrpc > -1)
{ {
jsonrpcServer = auto_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::HttpServer(jsonrpc), web3, {us})); jsonrpcServer = auto_ptr<WebThreeStubServer>(new WebThreeStubServer(new jsonrpc::HttpServer(jsonrpc), web3, {us}));
jsonrpcServer->StartListening(); jsonrpcServer->StartListening();
} }
#endif
while (true) while (true)
{ {
@ -526,6 +540,7 @@ int main(int argc, char** argv)
{ {
c.stopMining(); c.stopMining();
} }
#if ETH_JSONRPC
else if (cmd == "jsonport") else if (cmd == "jsonport")
{ {
if (iss.peek() != -1) if (iss.peek() != -1)
@ -545,6 +560,7 @@ int main(int argc, char** argv)
jsonrpcServer->StopListening(); jsonrpcServer->StopListening();
jsonrpcServer.reset(); jsonrpcServer.reset();
} }
#endif
else if (cmd == "address") else if (cmd == "address")
{ {
ccout << "Current address:" << endl; ccout << "Current address:" << endl;
@ -986,8 +1002,10 @@ int main(int argc, char** argv)
endwin(); endwin();
refresh(); refresh();
#if ETH_JSONRPC
if (jsonrpcServer.get()) if (jsonrpcServer.get())
jsonrpcServer->StopListening(); jsonrpcServer->StopListening();
#endif
return 0; return 0;
} }

4
test/CMakeLists.txt

@ -18,7 +18,9 @@ target_link_libraries(testeth gmp)
target_link_libraries(testeth solidity) target_link_libraries(testeth solidity)
target_link_libraries(testeth ${CRYPTOPP_LS}) target_link_libraries(testeth ${CRYPTOPP_LS})
target_link_libraries(testeth webthree) target_link_libraries(testeth webthree)
target_link_libraries(testeth ethrpc) if(JSONRPC_LS)
target_link_libraries(testeth web3jsonrpc)
endif()
target_link_libraries(createRandomTest ethereum) target_link_libraries(createRandomTest ethereum)
target_link_libraries(createRandomTest ethcore) target_link_libraries(createRandomTest ethcore)

4
test/jsonrpc.cpp

@ -27,8 +27,8 @@
#include <libdevcore/CommonIO.h> #include <libdevcore/CommonIO.h>
#include <libdevcore/CommonJS.h> #include <libdevcore/CommonJS.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#include <libethrpc/WebThreeStubServer.h> #include <libweb3jsonrpc/WebThreeStubServer.h>
#include <libethrpc/CorsHttpServer.h> #include <libweb3jsonrpc/CorsHttpServer.h>
#include <jsonrpc/connectors/httpserver.h> #include <jsonrpc/connectors/httpserver.h>
#include <jsonrpc/connectors/httpclient.h> #include <jsonrpc/connectors/httpclient.h>
#include <set> #include <set>

3
third/CMakeLists.txt

@ -53,8 +53,7 @@ else ()
endif () endif ()
qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets) qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)
target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore) target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore web3jsonrpc)
target_link_libraries(${EXECUTEABLE} ethrpc)
if (APPLE) if (APPLE)
# First have qt5 install plugins and frameworks # First have qt5 install plugins and frameworks

2
third/MainWin.cpp

@ -39,7 +39,7 @@
#include <libethereum/Client.h> #include <libethereum/Client.h>
#include <libethereum/EthereumHost.h> #include <libethereum/EthereumHost.h>
#include <libwebthree/WebThree.h> #include <libwebthree/WebThree.h>
#include <libethrpc/WebThreeStubServer.h> #include <libweb3jsonrpc/WebThreeStubServer.h>
#include "BuildInfo.h" #include "BuildInfo.h"
#include "MainWin.h" #include "MainWin.h"
#include "ui_Main.h" #include "ui_Main.h"

Loading…
Cancel
Save