Browse Source

missing setDefaultBlock method

cl-refactor
Marek Kotewicz 11 years ago
parent
commit
c5a1df4700
  1. 12
      libweb3jsonrpc/WebThreeStubServer.cpp
  2. 1
      libweb3jsonrpc/WebThreeStubServer.h
  3. 7
      libweb3jsonrpc/abstractwebthreestubserver.h
  4. 1
      libweb3jsonrpc/spec.json
  5. 13
      test/webthreestubclient.h

12
libweb3jsonrpc/WebThreeStubServer.cpp

@ -343,10 +343,20 @@ int WebThreeStubServer::peerCount()
bool WebThreeStubServer::setCoinbase(std::string const& _address)
{
if (!client())
return false;
client()->setAddress(jsToAddress(_address));
return true;
}
bool WebThreeStubServer::setDefaultBlock(int const& _block)
{
if (!client())
return false;
client()->setDefault(_block);
return true;
}
bool WebThreeStubServer::setListening(bool const& _listening)
{
if (_listening)
@ -359,7 +369,7 @@ bool WebThreeStubServer::setListening(bool const& _listening)
bool WebThreeStubServer::setMining(bool const& _mining)
{
if (!client())
return Json::nullValue;
return false;
if (_mining)
client()->startMining();

1
libweb3jsonrpc/WebThreeStubServer.h

@ -58,6 +58,7 @@ public:
virtual int number();
virtual int peerCount();
virtual bool setCoinbase(std::string const& _address);
virtual bool setDefaultBlock(int const& _block);
virtual bool setListening(bool const& _listening);
virtual bool setMining(bool const& _mining);
virtual std::string stateAt(std::string const& _address, std::string const& _storage);

7
libweb3jsonrpc/abstractwebthreestubserver.h

@ -33,6 +33,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(new jsonrpc::Procedure("number", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::numberI);
this->bindAndAddMethod(new jsonrpc::Procedure("peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::peerCountI);
this->bindAndAddMethod(new jsonrpc::Procedure("setCoinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::setCoinbaseI);
this->bindAndAddMethod(new jsonrpc::Procedure("setDefaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::setDefaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("setListening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::setListeningI);
this->bindAndAddMethod(new jsonrpc::Procedure("setMining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::setMiningI);
this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::stateAtI);
@ -145,6 +146,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
response = this->setCoinbase(request[0u].asString());
}
inline virtual void setDefaultBlockI(const Json::Value& request, Json::Value& response)
{
response = this->setDefaultBlock(request[0u].asInt());
}
inline virtual void setListeningI(const Json::Value& request, Json::Value& response)
{
response = this->setListening(request[0u].asBool());
@ -211,6 +217,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual int number() = 0;
virtual int peerCount() = 0;
virtual bool setCoinbase(const std::string& param1) = 0;
virtual bool setDefaultBlock(const int& param1) = 0;
virtual bool setListening(const bool& param1) = 0;
virtual bool setMining(const bool& param1) = 0;
virtual std::string stateAt(const std::string& param1, const std::string& param2) = 0;

1
libweb3jsonrpc/spec.json

@ -9,6 +9,7 @@
{ "method": "accounts", "params": [], "order": [], "returns" : [] },
{ "method": "peerCount", "params": [], "order": [], "returns" : 0 },
{ "method": "defaultBlock", "params": [], "order": [], "returns" : 0},
{ "method": "setDefaultBlock", "params": [0], "order": [], "returns" : true},
{ "method": "number", "params": [], "order": [], "returns" : 0},
{ "method": "balanceAt", "params": [""], "order": [], "returns" : ""},

13
test/webthreestubclient.h

@ -271,6 +271,19 @@ class WebThreeStubClient
}
bool setDefaultBlock(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->client->CallMethod("setDefaultBlock",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool setListening(const bool& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;

Loading…
Cancel
Save