From 7f67696fc7d3aae144769d4cd4677330ad0a79e5 Mon Sep 17 00:00:00 2001 From: KKudryavtsev Date: Tue, 13 May 2014 12:58:41 +0100 Subject: [PATCH] added "order"s back into the json; fixed styling issues --- eth/EthStubServer.cpp | 26 ++++++++++---------------- eth/EthStubServer.h | 4 ++-- eth/spec.json | 18 +++++++++--------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/eth/EthStubServer.cpp b/eth/EthStubServer.cpp index 1731de195..86a05e883 100644 --- a/eth/EthStubServer.cpp +++ b/eth/EthStubServer.cpp @@ -8,15 +8,15 @@ cpp-ethereum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + along with cpp-ethereum. If not, see . */ /** @file EthStubServer.cpp * @authors: - * Gav Wood + * Gav Wood * @date 2014 */ @@ -27,15 +27,12 @@ using namespace std; using namespace eth; - - EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, Client& _client): AbstractEthStubServer(_conn), m_client(_client) { } - //only works with a json spec that doesn't have notifications for now Json::Value EthStubServer::procedures() { @@ -48,10 +45,8 @@ Json::Value EthStubServer::procedures() proc_j[proc.second->GetProcedureType() == 0 ? "method" : "notification"] = proc.first; Json::Value params_j; - for(auto params : proc.second->GetParameters()) - { + for (auto params: proc.second->GetParameters()) params_j[params.first] = jsontypeToValue(params.second); - } proc_j["params"] = params_j; proc_j["returns"] = jsontypeToValue(proc.second->GetReturnType()); @@ -163,17 +158,17 @@ Json::Value EthStubServer::lastBlock() return blockJson(""); } -Json::Value EthStubServer::block(const std::string& hash) +Json::Value EthStubServer::block(const std::string& _hash) { - return blockJson(hash); + return blockJson(_hash); } -Json::Value EthStubServer::blockJson(const std::string& hash) +Json::Value EthStubServer::blockJson(const std::string& _hash) { Json::Value res; auto const& bc = m_client.blockChain(); - auto b = hash.length() ? bc.block(h256(hash)) : bc.block(); + auto b = _hash.length() ? bc.block(h256(_hash)) : bc.block(); auto bi = BlockInfo(b); res["number"] = to_string(bc.details(bc.currentHash()).number); @@ -193,10 +188,9 @@ Json::Value EthStubServer::blockJson(const std::string& hash) return res; } -Json::Value EthStubServer::jsontypeToValue(int jsontype) +Json::Value EthStubServer::jsontypeToValue(int _jsontype) { - cout<< jsontype << endl; - switch(jsontype) + switch (_jsontype) { case jsonrpc::JSON_STRING: return ""; //Json::stringValue segfault, fuck knows why case jsonrpc::JSON_BOOLEAN: return Json::booleanValue; diff --git a/eth/EthStubServer.h b/eth/EthStubServer.h index 51778807d..9677885bf 100644 --- a/eth/EthStubServer.h +++ b/eth/EthStubServer.h @@ -8,11 +8,11 @@ cpp-ethereum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . + along with cpp-ethereum. If not, see . */ /** @file EthStubServer.h * @author Gav Wood diff --git a/eth/spec.json b/eth/spec.json index 537a7c0e1..51d042a0d 100644 --- a/eth/spec.json +++ b/eth/spec.json @@ -7,16 +7,16 @@ { "method": "key", "params": null, "returns" : "" }, { "method": "keys", "params": null, "returns" : [] }, { "method": "peerCount", "params": null, "returns" : 0 }, - { "method": "balanceAt", "params": { "a": "" }, "returns" : "" }, - { "method": "storageAt", "params": { "a": "", "x": "" }, "returns" : "" }, - { "method": "txCountAt", "params": { "a": "" }, "returns" : "" }, - { "method": "isContractAt", "params": { "a": "" }, "returns" : false }, - { "method": "create", "params": { "sec": "", "xEndowment": "", "bCode": "", "xGas": "", "xGasPrice": "" }, "returns": {} }, - { "method": "transact", "params": { "sec": "", "xValue": "", "aDest": "", "bData": "", "xGas": "", "xGasPrice": "" }, "returns": {} }, - { "method": "secretToAddress", "params": { "a": "" }, "returns" : "" }, - { "method": "check", "params": { "a": [] }, "returns" : [] }, + { "method": "balanceAt", "params": { "a": "" }, "order": ["a"], "returns" : "" }, + { "method": "storageAt", "params": { "a": "", "x": "" }, "order": ["a", "x"], "returns" : "" }, + { "method": "txCountAt", "params": { "a": "" },"order": ["a"], "returns" : "" }, + { "method": "isContractAt", "params": { "a": "" }, "order": ["a"], "returns" : false }, + { "method": "create", "params": { "sec": "", "xEndowment": "", "bCode": "", "xGas": "", "xGasPrice": "" }, "order": ["sec", "xEndowment", "bCode", "xGas", "xGasPrice"] , "returns": {} }, + { "method": "transact", "params": { "sec": "", "xValue": "", "aDest": "", "bData": "", "xGas": "", "xGasPrice": "" }, "order": ["sec", "xValue", "aDest", "bData", "xGas", "xGasPrice"], "returns": {} }, + { "method": "secretToAddress", "params": { "a": "" }, "order": ["a"], "returns" : "" }, + { "method": "check", "params": { "a": [] }, "order": ["a"], "returns" : [] }, { "method": "lastBlock", "params": null, "returns": {}}, - { "method": "block", "params": {"a":""}, "returns": {}} + { "method": "block", "params": {"a":""}, "order": ["a"], "returns": {}} ]