Browse Source

Merge pull request #2636 from LefterisJP/js_nodeInfo

Add new js admin nodeInfo command
cl-refactor
Gav Wood 10 years ago
parent
commit
eff508d260
  1. 5
      libjsqrc/admin.js
  2. 6
      libweb3jsonrpc/abstractwebthreestubserver.h
  3. 1
      libweb3jsonrpc/spec.json
  4. 4
      mix/Web3Server.cpp
  5. 12
      test/libweb3jsonrpc/webthreestubclient.h

5
libjsqrc/admin.js

@ -35,6 +35,11 @@ web3._extend({
call: 'admin_eth_blockQueueStatus', call: 'admin_eth_blockQueueStatus',
inputFormatter: [getSessionKey], inputFormatter: [getSessionKey],
params: 1 params: 1
}), new web3._extend.Method({
name: 'net.nodeInfo',
call: 'admin_net_nodeInfo',
inputFormatter: [getSessionKey],
params: 1
}), new web3._extend.Method({ }), new web3._extend.Method({
name: 'eth.setAskPrice', name: 'eth.setAskPrice',
call: 'admin_eth_setAskPrice', call: 'admin_eth_setAskPrice',

6
libweb3jsonrpc/abstractwebthreestubserver.h

@ -84,6 +84,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(jsonrpc::Procedure("admin_net_connect", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_net_connectI); this->bindAndAddMethod(jsonrpc::Procedure("admin_net_connect", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_net_connectI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_net_peers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_net_peersI); this->bindAndAddMethod(jsonrpc::Procedure("admin_net_peers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_net_peersI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_blockQueueStatus", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_blockQueueStatusI); this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_blockQueueStatus", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_blockQueueStatusI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_net_nodeInfo", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_net_nodeInfoI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setAskPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setAskPriceI); this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setAskPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setAskPriceI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setBidPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setBidPriceI); this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setBidPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setBidPriceI);
this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setReferencePrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setReferencePriceI); this->bindAndAddMethod(jsonrpc::Procedure("admin_eth_setReferencePrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::admin_eth_setReferencePriceI);
@ -407,6 +408,10 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
{ {
response = this->admin_eth_blockQueueStatus(request[0u].asString()); response = this->admin_eth_blockQueueStatus(request[0u].asString());
} }
inline virtual void admin_net_nodeInfoI(const Json::Value &request, Json::Value &response)
{
response = this->admin_net_nodeInfo(request[0u].asString());
}
inline virtual void admin_eth_setAskPriceI(const Json::Value &request, Json::Value &response) inline virtual void admin_eth_setAskPriceI(const Json::Value &request, Json::Value &response)
{ {
response = this->admin_eth_setAskPrice(request[0u].asString(), request[1u].asString()); response = this->admin_eth_setAskPrice(request[0u].asString(), request[1u].asString());
@ -543,6 +548,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual bool admin_net_connect(const std::string& param1, const std::string& param2) = 0; virtual bool admin_net_connect(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value admin_net_peers(const std::string& param1) = 0; virtual Json::Value admin_net_peers(const std::string& param1) = 0;
virtual Json::Value admin_eth_blockQueueStatus(const std::string& param1) = 0; virtual Json::Value admin_eth_blockQueueStatus(const std::string& param1) = 0;
virtual Json::Value admin_net_nodeInfo(const std::string& param1) = 0;
virtual bool admin_eth_setAskPrice(const std::string& param1, const std::string& param2) = 0; virtual bool admin_eth_setAskPrice(const std::string& param1, const std::string& param2) = 0;
virtual bool admin_eth_setBidPrice(const std::string& param1, const std::string& param2) = 0; virtual bool admin_eth_setBidPrice(const std::string& param1, const std::string& param2) = 0;
virtual bool admin_eth_setReferencePrice(const std::string& param1, const std::string& param2) = 0; virtual bool admin_eth_setReferencePrice(const std::string& param1, const std::string& param2) = 0;

1
libweb3jsonrpc/spec.json

@ -76,6 +76,7 @@
{ "name": "admin_net_connect", "params": ["", ""], "returns": true }, { "name": "admin_net_connect", "params": ["", ""], "returns": true },
{ "name": "admin_net_peers", "params": [""], "returns": [] }, { "name": "admin_net_peers", "params": [""], "returns": [] },
{ "name": "admin_eth_blockQueueStatus", "params": [""], "returns": {}}, { "name": "admin_eth_blockQueueStatus", "params": [""], "returns": {}},
{ "name": "admin_net_nodeInfo", "params": [""], "returns": {}},
{ "name": "admin_eth_setAskPrice", "params": ["", ""], "returns": true }, { "name": "admin_eth_setAskPrice", "params": ["", ""], "returns": true },
{ "name": "admin_eth_setBidPrice", "params": ["", ""], "returns": true }, { "name": "admin_eth_setBidPrice", "params": ["", ""], "returns": true },
{ "name": "admin_eth_setReferencePrice", "params": ["", ""], "returns": true }, { "name": "admin_eth_setReferencePrice", "params": ["", ""], "returns": true },

4
mix/Web3Server.cpp

@ -83,6 +83,10 @@ class EmptyNetwork : public dev::WebThreeNetworkFace
(void)_dropPeers; (void)_dropPeers;
} }
p2p::NodeInfo nodeInfo() const override { return p2p::NodeInfo(); }
std::string enode() const override { return ""; }
p2p::NodeId id() const override p2p::NodeId id() const override
{ {
return p2p::NodeId(); return p2p::NodeId();

12
test/libweb3jsonrpc/webthreestubclient.h

@ -747,7 +747,17 @@ class WebThreeStubClient : public jsonrpc::Client
{ {
Json::Value p; Json::Value p;
p.append(param1); p.append(param1);
Json::Value result = this->CallMethod("admin_eth_blockQueueStatus",p); Json::Value result = this->CallMethod("admin_eth_blockQueueStatus", p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value admin_net_nodeInfo(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("admin_net_nodeInfo",p);
if (result.isObject()) if (result.isObject())
return result; return result;
else else

Loading…
Cancel
Save