Browse Source

net_version

web3_clientVersion
cl-refactor
Gav Wood 10 years ago
parent
commit
97bba263eb
  1. 2
      libweb3jsonrpc/WebThreeStubServerBase.h
  2. 14
      libweb3jsonrpc/abstractwebthreestubserver.h
  3. 2
      libweb3jsonrpc/spec.json
  4. 20
      test/webthreestubclient.h

2
libweb3jsonrpc/WebThreeStubServerBase.h

@ -68,7 +68,9 @@ public:
WebThreeStubServerBase(jsonrpc::AbstractServerConnector& _conn, std::vector<dev::KeyPair> 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();

14
libweb3jsonrpc/abstractwebthreestubserver.h

@ -13,6 +13,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
AbstractWebThreeStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractWebThreeStubServer>(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::AbstractServer<AbstractWebThr
{
response = this->web3_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::AbstractServer<AbstractWebThr
response = this->shh_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;

2
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 },

20
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;

Loading…
Cancel
Save