Browse Source

Merge branch 'eth_newPendingTransactionFilter' into filter_blockHash

Conflicts:
	libweb3jsonrpc/WebThreeStubServerBase.h
	libweb3jsonrpc/abstractwebthreestubserver.h
	libweb3jsonrpc/spec.json
	test/libweb3jsonrpc/webthreestubclient.h
cl-refactor
Marek Kotewicz 10 years ago
parent
commit
99cd21ca37
  1. 16
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  2. 3
      libweb3jsonrpc/WebThreeStubServerBase.h
  3. 14
      libweb3jsonrpc/abstractwebthreestubserver.h
  4. 3
      libweb3jsonrpc/spec.json
  5. 14
      test/libweb3jsonrpc/webthreestubclient.h

16
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -862,17 +862,15 @@ string WebThreeStubServerBase::eth_newFilterEx(Json::Value const& _json)
}
}
string WebThreeStubServerBase::eth_newBlockFilter(string const& _filter)
string WebThreeStubServerBase::eth_newBlockFilter()
{
h256 filter;
if (_filter.compare("chain") == 0 || _filter.compare("latest") == 0)
filter = dev::eth::ChainChangedFilter;
else if (_filter.compare("pending") == 0)
filter = dev::eth::PendingChangedFilter;
else
BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
h256 filter = dev::eth::ChainChangedFilter;
return toJS(client()->installWatch(filter));
}
string WebThreeStubServerBase::eth_newPendingTransactionFilter()
{
h256 filter = dev::eth::PendingChangedFilter;
return toJS(client()->installWatch(filter));
}

3
libweb3jsonrpc/WebThreeStubServerBase.h

@ -106,7 +106,8 @@ public:
virtual Json::Value eth_compileSolidity(std::string const& _code);
virtual std::string eth_newFilter(Json::Value const& _json);
virtual std::string eth_newFilterEx(Json::Value const& _json);
virtual std::string eth_newBlockFilter(std::string const& _filter);
virtual std::string eth_newBlockFilter();
virtual std::string eth_newPendingTransactionFilter();
virtual bool eth_uninstallFilter(std::string const& _filterId);
virtual Json::Value eth_getFilterChanges(std::string const& _filterId);
virtual Json::Value eth_getFilterChangesEx(std::string const& _filterId);

14
libweb3jsonrpc/abstractwebthreestubserver.h

@ -48,7 +48,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(jsonrpc::Procedure("eth_compileSolidity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_compileSolidityI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilterEx", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterExI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newBlockFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newBlockFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newBlockFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newBlockFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newPendingTransactionFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newPendingTransactionFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_uninstallFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getFilterChanges", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getFilterChangesI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getFilterChangesEx", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getFilterChangesExI);
@ -235,7 +236,13 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
}
inline virtual void eth_newBlockFilterI(const Json::Value &request, Json::Value &response)
{
response = this->eth_newBlockFilter(request[0u].asString());
(void)request;
response = this->eth_newBlockFilter();
}
inline virtual void eth_newPendingTransactionFilterI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_newPendingTransactionFilter();
}
inline virtual void eth_uninstallFilterI(const Json::Value &request, Json::Value &response)
{
@ -375,7 +382,8 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual Json::Value eth_compileSolidity(const std::string& param1) = 0;
virtual std::string eth_newFilter(const Json::Value& param1) = 0;
virtual std::string eth_newFilterEx(const Json::Value& param1) = 0;
virtual std::string eth_newBlockFilter(const std::string& param1) = 0;
virtual std::string eth_newBlockFilter() = 0;
virtual std::string eth_newPendingTransactionFilter() = 0;
virtual bool eth_uninstallFilter(const std::string& param1) = 0;
virtual Json::Value eth_getFilterChanges(const std::string& param1) = 0;
virtual Json::Value eth_getFilterChangesEx(const std::string& param1) = 0;

3
libweb3jsonrpc/spec.json

@ -37,7 +37,8 @@
{ "name": "eth_compileSolidity", "params": [""], "order": [], "returns": {}},
{ "name": "eth_newFilter", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_newFilterEx", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_newBlockFilter", "params": [""], "order": [], "returns": ""},
{ "name": "eth_newBlockFilter", "params": [], "order": [], "returns": ""},
{ "name": "eth_newPendingTransactionFilter", "params": [], "order": [], "returns": ""},
{ "name": "eth_uninstallFilter", "params": [""], "order": [], "returns": true},
{ "name": "eth_getFilterChanges", "params": [""], "order": [], "returns": []},
{ "name": "eth_getFilterChangesEx", "params": [""], "order": [], "returns": []},

14
test/libweb3jsonrpc/webthreestubclient.h

@ -384,16 +384,26 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_newBlockFilter(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_newBlockFilter() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_newBlockFilter",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_newPendingTransactionFilter() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_newPendingTransactionFilter",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;

Loading…
Cancel
Save