Browse Source

Phone home :-)

cl-refactor
Gav Wood 10 years ago
parent
commit
6b172571a7
  1. 1
      eth/CMakeLists.txt
  2. 28
      eth/PhoneHome.h
  3. 20
      eth/main.cpp
  4. 3
      eth/phonehome.json
  5. 4
      eth/spec.json

1
eth/CMakeLists.txt

@ -22,6 +22,7 @@ if (READLINE_FOUND)
endif() endif()
if (JSONRPC) if (JSONRPC)
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES})
target_link_libraries(${EXECUTABLE} web3jsonrpc) target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif() endif()

28
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 <jsonrpccpp/client.h>
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_

20
eth/main.cpp

@ -45,11 +45,10 @@
#if ETH_JSONRPC || !ETH_TRUE #if ETH_JSONRPC || !ETH_TRUE
#include <libweb3jsonrpc/WebThreeStubServer.h> #include <libweb3jsonrpc/WebThreeStubServer.h>
#include <jsonrpccpp/server/connectors/httpserver.h> #include <jsonrpccpp/server/connectors/httpserver.h>
#endif #include <jsonrpccpp/client/connectors/httpclient.h>
#if ETH_CURL || !ETH_TRUE
#include <curl/curl.h>
#endif #endif
#include "BuildInfo.h" #include "BuildInfo.h"
#include "PhoneHome.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::p2p; 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; cout << "inner mean: " << (innerMean / (_trials - 2)) << " H/s" << endl;
(void)_phoneHome; (void)_phoneHome;
#if ETH_JSONRPC || !ETH_TRUE
if (_phoneHome) if (_phoneHome)
{ {
cout << "Phoning home to find world ranking..." << endl; cout << "Phoning home to find world ranking..." << endl;
jsonrpc::HttpClient client("http://192.168.33.39:3000/benchmark");
// TODO: send f.miningInfo() along with f.platformInfo() to Marian. 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); exit(0);
} }

3
eth/phonehome.json

@ -0,0 +1,3 @@
[
{ "name": "report_benchmark", "params": [ "", 0 ], "order": [], "returns": 0 }
]

4
eth/spec.json

@ -0,0 +1,4 @@
[
{ "name": "eth_getWork", "params": [], "order": [], "returns": []},
{ "name": "eth_submitWork", "params": ["", ""], "order": [], "returns": true}
]
Loading…
Cancel
Save