diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index fbc6a8b24..bd6b8d354 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -22,6 +22,7 @@ if (READLINE_FOUND) endif() if (JSONRPC) + target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) target_link_libraries(${EXECUTABLE} web3jsonrpc) endif() diff --git a/eth/PhoneHome.h b/eth/PhoneHome.h new file mode 100644 index 000000000..ae6091cc2 --- /dev/null +++ b/eth/PhoneHome.h @@ -0,0 +1,28 @@ +/** + * This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY! + */ + +#ifndef JSONRPC_CPP_STUB_PHONEHOME_H_ +#define JSONRPC_CPP_STUB_PHONEHOME_H_ + +#include + +class PhoneHome : public jsonrpc::Client +{ + public: + PhoneHome(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {} + + int report_benchmark(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p.append(param1); + p.append(param2); + Json::Value result = this->CallMethod("report_benchmark",p); + if (result.isInt()) + return result.asInt(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } +}; + +#endif //JSONRPC_CPP_STUB_PHONEHOME_H_ diff --git a/eth/main.cpp b/eth/main.cpp index be12e3668..8eebe3395 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -45,11 +45,10 @@ #if ETH_JSONRPC || !ETH_TRUE #include #include -#endif -#if ETH_CURL || !ETH_TRUE -#include +#include #endif #include "BuildInfo.h" +#include "PhoneHome.h" using namespace std; using namespace dev; using namespace dev::p2p; @@ -304,12 +303,23 @@ void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, u cout << "inner mean: " << (innerMean / (_trials - 2)) << " H/s" << endl; (void)_phoneHome; +#if ETH_JSONRPC || !ETH_TRUE if (_phoneHome) { cout << "Phoning home to find world ranking..." << endl; - - // TODO: send f.miningInfo() along with f.platformInfo() to Marian. + jsonrpc::HttpClient client("http://192.168.33.39:3000/benchmark"); + PhoneHome rpc(client); + try + { + unsigned ranking = rpc.report_benchmark(platformInfo, innerMean); + cout << "Ranked: " << ranking << " of all benchmarks." << endl; + } + catch (...) + { + cout << "Error phoning home. ET is sad." << endl; + } } +#endif exit(0); } diff --git a/eth/phonehome.json b/eth/phonehome.json new file mode 100644 index 000000000..0bed56d72 --- /dev/null +++ b/eth/phonehome.json @@ -0,0 +1,3 @@ +[ + { "name": "report_benchmark", "params": [ "", 0 ], "order": [], "returns": 0 } +] diff --git a/eth/spec.json b/eth/spec.json new file mode 100644 index 000000000..24f0c163e --- /dev/null +++ b/eth/spec.json @@ -0,0 +1,4 @@ +[ + { "name": "eth_getWork", "params": [], "order": [], "returns": []}, + { "name": "eth_submitWork", "params": ["", ""], "order": [], "returns": true} +]