Browse Source

jsonrpc library dependency made mandatory

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
74e43cfb57
  1. 2
      CMakeLists.txt
  2. 3
      eth/CMakeLists.txt
  3. 20
      eth/main.cpp
  4. 2
      libethrpc/CMakeLists.txt
  5. 6
      libethrpc/WebThreeStubServer.cpp
  6. 2
      libqethereum/QEthereum.cpp
  7. 3
      neth/CMakeLists.txt
  8. 24
      neth/main.cpp
  9. 3
      test/CMakeLists.txt
  10. 2
      test/jsonrpc.cpp

2
CMakeLists.txt

@ -117,9 +117,7 @@ endif()
add_subdirectory(lllc)
add_subdirectory(sc)
if(JSONRPC_LS)
add_subdirectory(libethrpc)
endif()
if (NOT LANGUAGES)
add_subdirectory(secp256k1)
add_subdirectory(libp2p)

3
eth/CMakeLists.txt

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

20
eth/main.cpp

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

2
libethrpc/CMakeLists.txt

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

6
libethrpc/WebThreeStubServer.cpp

@ -21,7 +21,6 @@
* @date 2014
*/
#if ETH_JSONRPC
#include "WebThreeStubServer.h"
#include <libevmface/Instruction.h>
#include <liblll/Compiler.h>
@ -173,7 +172,7 @@ Json::Value WebThreeStubServer::accounts()
std::string WebThreeStubServer::balanceAt(string const& _address)
{
int block = 0; // temporarily
int block = 0;
return toJS(client()->balanceAt(jsToAddress(_address), block));
}
@ -264,7 +263,6 @@ bool WebThreeStubServer::changed(int const& _id)
std::string WebThreeStubServer::codeAt(string const& _address)
{
// temp
int block = 0;
return client() ? jsFromBinary(client()->codeAt(jsToAddress(_address), block)) : "";
}
@ -372,7 +370,6 @@ bool WebThreeStubServer::setMining(bool const& _mining)
std::string WebThreeStubServer::stateAt(string const& _address, string const& _storage)
{
// temp
int block = 0;
return client() ? toJS(client()->stateAt(jsToAddress(_address), jsToU256(_storage), block)) : "";
}
@ -447,4 +444,3 @@ bool WebThreeStubServer::uninstallFilter(int const& _id)
return true;
}
#endif

2
libqethereum/QEthereum.cpp

@ -82,8 +82,8 @@ void QWebThree::clearWatches()
void QWebThree::clientDieing()
{
clearWatches();
this->disconnect();
clearWatches();
}
static QString formatInput(QJsonObject const& _object)

3
neth/CMakeLists.txt

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

24
neth/main.cpp

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

3
test/CMakeLists.txt

@ -17,10 +17,7 @@ target_link_libraries(testeth secp256k1)
target_link_libraries(testeth gmp)
target_link_libraries(testeth ${CRYPTOPP_LS})
target_link_libraries(testeth webthree)
if(JSONRPC_LS)
target_link_libraries(testeth ethrpc)
endif()
target_link_libraries(createRandomTest ethereum)
target_link_libraries(createRandomTest ethcore)

2
test/jsonrpc.cpp

@ -19,7 +19,7 @@
* @date 2014
*/
#if ETH_JSONRPC && 1
#if 1
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>

Loading…
Cancel
Save