From 97bba263eb2f1e0daf8c29f1aaa6a7bbbc991ce5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 12 Mar 2015 13:38:51 +0000 Subject: [PATCH] net_version web3_clientVersion --- libweb3jsonrpc/WebThreeStubServerBase.h | 6 ++++-- libweb3jsonrpc/abstractwebthreestubserver.h | 14 ++++++++++++++ libweb3jsonrpc/spec.json | 2 ++ test/webthreestubclient.h | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/libweb3jsonrpc/WebThreeStubServerBase.h b/libweb3jsonrpc/WebThreeStubServerBase.h index e0445bf60..c71d7ee30 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.h +++ b/libweb3jsonrpc/WebThreeStubServerBase.h @@ -68,10 +68,12 @@ public: WebThreeStubServerBase(jsonrpc::AbstractServerConnector& _conn, std::vector const& _accounts); virtual std::string web3_sha3(std::string const& _param1); - + virtual std::string web3_clientVersion() { return "C++ (ethereum-cpp)"; } + + virtual std::string net_version() { return ""; } virtual std::string net_peerCount(); virtual bool net_listening(); - + virtual std::string eth_coinbase(); virtual bool eth_mining(); virtual std::string eth_gasPrice(); diff --git a/libweb3jsonrpc/abstractwebthreestubserver.h b/libweb3jsonrpc/abstractwebthreestubserver.h index 3378745ec..cc326183d 100644 --- a/libweb3jsonrpc/abstractwebthreestubserver.h +++ b/libweb3jsonrpc/abstractwebthreestubserver.h @@ -13,6 +13,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer(conn, type) { this->bindAndAddMethod(jsonrpc::Procedure("web3_sha3", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::web3_sha3I); + this->bindAndAddMethod(jsonrpc::Procedure("web3_clientVersion", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::web3_clientVersionI); + this->bindAndAddMethod(jsonrpc::Procedure("net_version", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::net_versionI); this->bindAndAddMethod(jsonrpc::Procedure("net_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::net_peerCountI); this->bindAndAddMethod(jsonrpc::Procedure("net_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::net_listeningI); this->bindAndAddMethod(jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI); @@ -71,6 +73,16 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServerweb3_sha3(request[0u].asString()); } + inline virtual void web3_clientVersionI(const Json::Value &request, Json::Value &response) + { + (void)request; + response = this->web3_clientVersion(); + } + inline virtual void net_versionI(const Json::Value &request, Json::Value &response) + { + (void)request; + response = this->net_version(); + } inline virtual void net_peerCountI(const Json::Value &request, Json::Value &response) { (void)request; @@ -291,6 +303,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServershh_getMessages(request[0u].asString()); } virtual std::string web3_sha3(const std::string& param1) = 0; + virtual std::string web3_clientVersion() = 0; + virtual std::string net_version() = 0; virtual std::string net_peerCount() = 0; virtual bool net_listening() = 0; virtual std::string eth_coinbase() = 0; diff --git a/libweb3jsonrpc/spec.json b/libweb3jsonrpc/spec.json index 3db2039ce..6fb947f39 100644 --- a/libweb3jsonrpc/spec.json +++ b/libweb3jsonrpc/spec.json @@ -1,6 +1,8 @@ [ { "name": "web3_sha3", "params": [""], "order": [], "returns" : "" }, + { "name": "web3_clientVersion", "params": [], "order": [], "returns" : "" }, + { "name": "net_version", "params": [], "order": [], "returns" : "" }, { "name": "net_peerCount", "params": [], "order": [], "returns" : "" }, { "name": "net_listening", "params": [], "order": [], "returns" : false }, diff --git a/test/webthreestubclient.h b/test/webthreestubclient.h index baa0798ae..687ebc491 100644 --- a/test/webthreestubclient.h +++ b/test/webthreestubclient.h @@ -22,6 +22,26 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } + std::string web3_clientVersion() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("web3_clientVersion",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } + std::string net_version() throw (jsonrpc::JsonRpcException) + { + Json::Value p; + p = Json::nullValue; + Json::Value result = this->CallMethod("net_version",p); + if (result.isString()) + return result.asString(); + else + throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); + } std::string net_peerCount() throw (jsonrpc::JsonRpcException) { Json::Value p;