Browse Source

libethrpc retab

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
a54b6b1ae2
  1. 26
      libethrpc/CorsHttpServer.cpp
  2. 5
      libethrpc/CorsHttpServer.h
  3. 386
      libethrpc/EthStubServer.cpp
  4. 72
      libethrpc/EthStubServer.h
  5. 16
      libqethereum/QEthereum.h

26
libethrpc/CorsHttpServer.cpp

@ -23,20 +23,18 @@
namespace jsonrpc namespace jsonrpc
{ {
bool CorsHttpServer::SendResponse(const std::string &response, void *addInfo) bool CorsHttpServer::SendResponse(const std::string &response, void *addInfo)
{ {
struct mg_connection* conn = (struct mg_connection*) addInfo; struct mg_connection* conn = (struct mg_connection*) addInfo;
if (mg_printf(conn, "HTTP/1.1 200 OK\r\n" if (mg_printf(conn, "HTTP/1.1 200 OK\r\n"
"Content-Type: application/json\r\n" "Content-Type: application/json\r\n"
"Content-Length: %d\r\n" "Content-Length: %d\r\n"
"Access-Control-Allow-Origin: *\r\n" "Access-Control-Allow-Origin: *\r\n"
"Access-Control-Allow-Headers: Content-Type\r\n" "Access-Control-Allow-Headers: Content-Type\r\n"
"\r\n" "\r\n"
"%s",(int)response.length(), response.c_str()) > 0) "%s",(int)response.length(), response.c_str()) > 0)
return true; return true;
return false;
return false; }
}
} }

5
libethrpc/CorsHttpServer.h

@ -27,9 +27,8 @@ namespace jsonrpc
class CorsHttpServer : public HttpServer class CorsHttpServer : public HttpServer
{ {
public: public:
using HttpServer::HttpServer; using HttpServer::HttpServer;
bool virtual SendResponse(const std::string& response, bool virtual SendResponse(const std::string& response, void* addInfo = NULL);
void* addInfo = NULL);
}; };
} }

386
libethrpc/EthStubServer.cpp

@ -35,65 +35,65 @@ using namespace dev::eth;
static Json::Value toJson(const dev::eth::BlockInfo& bi) static Json::Value toJson(const dev::eth::BlockInfo& bi)
{ {
Json::Value res; Json::Value res;
res["hash"] = boost::lexical_cast<string>(bi.hash); res["hash"] = boost::lexical_cast<string>(bi.hash);
res["parentHash"] = toJS(bi.parentHash); res["parentHash"] = toJS(bi.parentHash);
res["sha3Uncles"] = toJS(bi.sha3Uncles); res["sha3Uncles"] = toJS(bi.sha3Uncles);
res["miner"] = toJS(bi.coinbaseAddress); res["miner"] = toJS(bi.coinbaseAddress);
res["stateRoot"] = toJS(bi.stateRoot); res["stateRoot"] = toJS(bi.stateRoot);
res["transactionsRoot"] = toJS(bi.transactionsRoot); res["transactionsRoot"] = toJS(bi.transactionsRoot);
res["difficulty"] = toJS(bi.difficulty); res["difficulty"] = toJS(bi.difficulty);
res["number"] = (int)bi.number; res["number"] = (int)bi.number;
res["minGasPrice"] = toJS(bi.minGasPrice); res["minGasPrice"] = toJS(bi.minGasPrice);
res["gasLimit"] = (int)bi.gasLimit; res["gasLimit"] = (int)bi.gasLimit;
res["timestamp"] = (int)bi.timestamp; res["timestamp"] = (int)bi.timestamp;
res["extraData"] = jsFromBinary(bi.extraData); res["extraData"] = jsFromBinary(bi.extraData);
res["nonce"] = toJS(bi.nonce); res["nonce"] = toJS(bi.nonce);
return res; return res;
} }
static Json::Value toJson(const dev::eth::PastMessage& t) static Json::Value toJson(const dev::eth::PastMessage& t)
{ {
Json::Value res; Json::Value res;
res["input"] = jsFromBinary(t.input); res["input"] = jsFromBinary(t.input);
res["output"] = jsFromBinary(t.output); res["output"] = jsFromBinary(t.output);
res["to"] = toJS(t.to); res["to"] = toJS(t.to);
res["from"] = toJS(t.from); res["from"] = toJS(t.from);
res["value"] = jsToDecimal(toJS(t.value)); res["value"] = jsToDecimal(toJS(t.value));
res["origin"] = toJS(t.origin); res["origin"] = toJS(t.origin);
res["timestamp"] = toJS(t.timestamp); res["timestamp"] = toJS(t.timestamp);
res["coinbase"] = toJS(t.coinbase); res["coinbase"] = toJS(t.coinbase);
res["block"] = toJS(t.block); res["block"] = toJS(t.block);
Json::Value path; Json::Value path;
for (int i: t.path) for (int i: t.path)
path.append(i); path.append(i);
res["path"] = path; res["path"] = path;
res["number"] = (int)t.number; res["number"] = (int)t.number;
return res; return res;
} }
static Json::Value toJson(const dev::eth::PastMessages& pms) static Json::Value toJson(const dev::eth::PastMessages& pms)
{ {
Json::Value res; Json::Value res;
for (dev::eth::PastMessage const & t: pms) for (dev::eth::PastMessage const & t: pms)
res.append(toJson(t)); res.append(toJson(t));
return res; return res;
} }
static Json::Value toJson(const dev::eth::Transaction& t) static Json::Value toJson(const dev::eth::Transaction& t)
{ {
Json::Value res; Json::Value res;
res["hash"] = toJS(t.sha3()); res["hash"] = toJS(t.sha3());
res["input"] = jsFromBinary(t.data); res["input"] = jsFromBinary(t.data);
res["to"] = toJS(t.receiveAddress); res["to"] = toJS(t.receiveAddress);
res["from"] = toJS(t.sender()); res["from"] = toJS(t.sender());
res["gas"] = (int)t.gas; res["gas"] = (int)t.gas;
res["gasPrice"] = toJS(t.gasPrice); res["gasPrice"] = toJS(t.gasPrice);
res["nonce"] = toJS(t.nonce); res["nonce"] = toJS(t.nonce);
res["value"] = toJS(t.value); res["value"] = toJS(t.value);
return res; return res;
} }
EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDirect& _web3): EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDirect& _web3):
@ -104,12 +104,12 @@ EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDi
dev::eth::Interface* EthStubServer::client() const dev::eth::Interface* EthStubServer::client() const
{ {
return m_web3.ethereum(); return m_web3.ethereum();
} }
std::string EthStubServer::balanceAt(const string &address, const int& block) std::string EthStubServer::balanceAt(const string &address, const int& block)
{ {
return toJS(client()->balanceAt(jsToAddress(address), block)); return toJS(client()->balanceAt(jsToAddress(address), block));
} }
dev::FixedHash<32> EthStubServer::numberOrHash(Json::Value const &json) const dev::FixedHash<32> EthStubServer::numberOrHash(Json::Value const &json) const
@ -133,93 +133,93 @@ Json::Value EthStubServer::block(const Json::Value &params)
static TransactionJS toTransaction(const Json::Value &json) static TransactionJS toTransaction(const Json::Value &json)
{ {
TransactionJS ret; TransactionJS ret;
if (!json.isObject() || json.empty()){ if (!json.isObject() || json.empty()){
return ret; return ret;
} }
if (!json["from"].empty()) if (!json["from"].empty())
ret.from = jsToSecret(json["from"].asString()); ret.from = jsToSecret(json["from"].asString());
if (!json["to"].empty()) if (!json["to"].empty())
ret.to = jsToAddress(json["to"].asString()); ret.to = jsToAddress(json["to"].asString());
if (!json["value"].empty()) if (!json["value"].empty())
ret.value = jsToU256(json["value"].asString()); ret.value = jsToU256(json["value"].asString());
if (!json["gas"].empty()) if (!json["gas"].empty())
ret.gas = jsToU256(json["gas"].asString()); ret.gas = jsToU256(json["gas"].asString());
if (!json["gasPrice"].empty()) if (!json["gasPrice"].empty())
ret.gasPrice = jsToU256(json["gasPrice"].asString()); ret.gasPrice = jsToU256(json["gasPrice"].asString());
if (!json["data"].empty() || json["code"].empty() || json["dataclose"].empty()) if (!json["data"].empty() || json["code"].empty() || json["dataclose"].empty())
{ {
if (json["data"].isString()) if (json["data"].isString())
ret.data = jsToBytes(json["data"].asString()); ret.data = jsToBytes(json["data"].asString());
else if (json["code"].isString()) else if (json["code"].isString())
ret.data = jsToBytes(json["code"].asString()); ret.data = jsToBytes(json["code"].asString());
else if (json["data"].isArray()) else if (json["data"].isArray())
for (auto i: json["data"]) for (auto i: json["data"])
dev::operator +=(ret.data, asBytes(jsPadded(i.asString(), 32))); dev::operator +=(ret.data, asBytes(jsPadded(i.asString(), 32)));
else if (json["code"].isArray()) else if (json["code"].isArray())
for (auto i: json["code"]) for (auto i: json["code"])
dev::operator +=(ret.data, asBytes(jsPadded(i.asString(), 32))); dev::operator +=(ret.data, asBytes(jsPadded(i.asString(), 32)));
else if (json["dataclose"].isArray()) else if (json["dataclose"].isArray())
for (auto i: json["dataclose"]) for (auto i: json["dataclose"])
dev::operator +=(ret.data, jsToBytes(i.asString())); dev::operator +=(ret.data, jsToBytes(i.asString()));
} }
return ret; return ret;
} }
std::string EthStubServer::call(const Json::Value &json) std::string EthStubServer::call(const Json::Value &json)
{ {
std::string ret; std::string ret;
if (!client()) if (!client())
return ret; return ret;
TransactionJS t = toTransaction(json); TransactionJS t = toTransaction(json);
if (!t.to) if (!t.to)
return ret; return ret;
if (!t.from && m_keys.size()) if (!t.from && m_keys.size())
t.from = m_keys[0].secret(); t.from = m_keys[0].secret();
if (!t.gasPrice) if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo; t.gasPrice = 10 * dev::eth::szabo;
if (!t.gas) if (!t.gas)
t.gas = client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice; t.gas = client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice;
ret = toJS(client()->call(t.from, t.value, t.to, t.data, t.gas, t.gasPrice)); ret = toJS(client()->call(t.from, t.value, t.to, t.data, t.gas, t.gasPrice));
return ret; return ret;
} }
std::string EthStubServer::codeAt(const string &address, const int& block) std::string EthStubServer::codeAt(const string &address, const int& block)
{ {
return client() ? jsFromBinary(client()->codeAt(jsToAddress(address), block)) : ""; return client() ? jsFromBinary(client()->codeAt(jsToAddress(address), block)) : "";
} }
std::string EthStubServer::coinbase() std::string EthStubServer::coinbase()
{ {
return client() ? toJS(client()->address()) : ""; return client() ? toJS(client()->address()) : "";
} }
double EthStubServer::countAt(const string &address, const int& block) double EthStubServer::countAt(const string &address, const int& block)
{ {
return client() ? (double)(uint64_t)client()->countAt(jsToAddress(address), block) : 0; return client() ? (double)(uint64_t)client()->countAt(jsToAddress(address), block) : 0;
} }
int EthStubServer::defaultBlock() int EthStubServer::defaultBlock()
{ {
return client() ? client()->getDefault() : 0; return client() ? client()->getDefault() : 0;
} }
std::string EthStubServer::fromAscii(const int& padding, const std::string& s) std::string EthStubServer::fromAscii(const int& padding, const std::string& s)
{ {
return jsFromBinary(s, padding); return jsFromBinary(s, padding);
} }
double EthStubServer::fromFixed(const string &s) double EthStubServer::fromFixed(const string &s)
{ {
return jsFromFixed(s); return jsFromFixed(s);
} }
std::string EthStubServer::gasPrice() std::string EthStubServer::gasPrice()
{ {
return toJS(10 * dev::eth::szabo); return toJS(10 * dev::eth::szabo);
} }
bool EthStubServer::listening() bool EthStubServer::listening()
@ -229,88 +229,88 @@ bool EthStubServer::listening()
bool EthStubServer::mining() bool EthStubServer::mining()
{ {
return client() ? client()->isMining() : false; return client() ? client()->isMining() : false;
} }
std::string EthStubServer::key() std::string EthStubServer::key()
{ {
if (!m_keys.size()) if (!m_keys.size())
return std::string(); return std::string();
return toJS(m_keys[0].sec()); return toJS(m_keys[0].sec());
} }
Json::Value EthStubServer::keys() Json::Value EthStubServer::keys()
{ {
Json::Value ret; Json::Value ret;
for (auto i: m_keys) for (auto i: m_keys)
ret.append(toJS(i.secret())); ret.append(toJS(i.secret()));
return ret; return ret;
} }
std::string EthStubServer::lll(const string &s) std::string EthStubServer::lll(const string &s)
{ {
return toJS(dev::eth::compileLLL(s)); return toJS(dev::eth::compileLLL(s));
} }
static dev::eth::MessageFilter toMessageFilter(const Json::Value &json) static dev::eth::MessageFilter toMessageFilter(const Json::Value &json)
{ {
dev::eth::MessageFilter filter; dev::eth::MessageFilter filter;
if (!json.isObject() || json.empty()){ if (!json.isObject() || json.empty()){
return filter; return filter;
} }
if (!json["earliest"].empty()) if (!json["earliest"].empty())
filter.withEarliest(json["earliest"].asInt()); filter.withEarliest(json["earliest"].asInt());
if (!json["latest"].empty()) if (!json["latest"].empty())
filter.withLatest(json["lastest"].asInt()); filter.withLatest(json["lastest"].asInt());
if (!json["max"].empty()) if (!json["max"].empty())
filter.withMax(json["max"].asInt()); filter.withMax(json["max"].asInt());
if (!json["skip"].empty()) if (!json["skip"].empty())
filter.withSkip(json["skip"].asInt()); filter.withSkip(json["skip"].asInt());
if (!json["from"].empty()) if (!json["from"].empty())
{ {
if (json["from"].isArray()) if (json["from"].isArray())
for (auto i : json["from"]) for (auto i : json["from"])
filter.from(jsToAddress(i.asString())); filter.from(jsToAddress(i.asString()));
else else
filter.from(jsToAddress(json["from"].asString())); filter.from(jsToAddress(json["from"].asString()));
} }
if (!json["to"].empty()) if (!json["to"].empty())
{ {
if (json["to"].isArray()) if (json["to"].isArray())
for (auto i : json["to"]) for (auto i : json["to"])
filter.from(jsToAddress(i.asString())); filter.from(jsToAddress(i.asString()));
else else
filter.from(jsToAddress(json["to"].asString())); filter.from(jsToAddress(json["to"].asString()));
} }
if (!json["altered"].empty()) if (!json["altered"].empty())
{ {
if (json["altered"].isArray()) if (json["altered"].isArray())
for (auto i: json["altered"]) for (auto i: json["altered"])
if (i.isObject()) if (i.isObject())
filter.altered(jsToAddress(i["id"].asString()), jsToU256(i["at"].asString())); filter.altered(jsToAddress(i["id"].asString()), jsToU256(i["at"].asString()));
else else
filter.altered((jsToAddress(i.asString()))); filter.altered((jsToAddress(i.asString())));
else if (json["altered"].isObject()) else if (json["altered"].isObject())
filter.altered(jsToAddress(json["altered"]["id"].asString()), jsToU256(json["altered"]["at"].asString())); filter.altered(jsToAddress(json["altered"]["id"].asString()), jsToU256(json["altered"]["at"].asString()));
else else
filter.altered(jsToAddress(json["altered"].asString())); filter.altered(jsToAddress(json["altered"].asString()));
} }
return filter; return filter;
} }
Json::Value EthStubServer::messages(const Json::Value &json) Json::Value EthStubServer::messages(const Json::Value &json)
{ {
Json::Value res; Json::Value res;
if (!client()) if (!client())
return res; return res;
return toJson(client()->messages(toMessageFilter(json))); return toJson(client()->messages(toMessageFilter(json)));
} }
int EthStubServer::number() int EthStubServer::number()
{ {
return client() ? client()->number() + 1 : 0; return client() ? client()->number() + 1 : 0;
} }
int EthStubServer::peerCount() int EthStubServer::peerCount()
@ -320,59 +320,59 @@ int EthStubServer::peerCount()
std::string EthStubServer::secretToAddress(const string &s) std::string EthStubServer::secretToAddress(const string &s)
{ {
return toJS(KeyPair(jsToSecret(s)).address()); return toJS(KeyPair(jsToSecret(s)).address());
} }
bool EthStubServer::setCoinbase(const std::string &address) bool EthStubServer::setCoinbase(const std::string &address)
{ {
client()->setAddress(jsToAddress(address)); client()->setAddress(jsToAddress(address));
return true; return true;
} }
bool EthStubServer::setListening(const bool &listening) bool EthStubServer::setListening(const bool &listening)
{ {
if (listening) if (listening)
m_web3.startNetwork(); m_web3.startNetwork();
else else
m_web3.stopNetwork(); m_web3.stopNetwork();
return true; return true;
} }
bool EthStubServer::setMining(const bool &mining) bool EthStubServer::setMining(const bool &mining)
{ {
if (!client()) if (!client())
return Json::nullValue; return Json::nullValue;
if (mining) if (mining)
client()->startMining(); client()->startMining();
else else
client()->stopMining(); client()->stopMining();
return true; return true;
} }
std::string EthStubServer::sha3(const string &s) std::string EthStubServer::sha3(const string &s)
{ {
return toJS(dev::eth::sha3(jsToBytes(s))); return toJS(dev::eth::sha3(jsToBytes(s)));
} }
std::string EthStubServer::stateAt(const string &address, const int& block, const string &storage) std::string EthStubServer::stateAt(const string &address, const int& block, const string &storage)
{ {
return client() ? toJS(client()->stateAt(jsToAddress(address), jsToU256(storage), block)) : ""; return client() ? toJS(client()->stateAt(jsToAddress(address), jsToU256(storage), block)) : "";
} }
std::string EthStubServer::toAscii(const string &s) std::string EthStubServer::toAscii(const string &s)
{ {
return jsToBinary(s); return jsToBinary(s);
} }
std::string EthStubServer::toDecimal(const string &s) std::string EthStubServer::toDecimal(const string &s)
{ {
return jsToDecimal(s); return jsToDecimal(s);
} }
std::string EthStubServer::toFixed(const double &s) std::string EthStubServer::toFixed(const double &s)
{ {
return jsToFixed(s); return jsToFixed(s);
} }
std::string EthStubServer::transact(const Json::Value &json) std::string EthStubServer::transact(const Json::Value &json)
@ -383,22 +383,22 @@ std::string EthStubServer::transact(const Json::Value &json)
TransactionJS t = toTransaction(json); TransactionJS t = toTransaction(json);
if (!t.from && m_keys.size()) if (!t.from && m_keys.size())
{ {
auto b = m_keys.front(); auto b = m_keys.front();
for (auto a: m_keys) for (auto a: m_keys)
if (client()->balanceAt(KeyPair(a).address()) > client()->balanceAt(KeyPair(b).address())) if (client()->balanceAt(KeyPair(a).address()) > client()->balanceAt(KeyPair(b).address()))
b = a; b = a;
t.from = b.secret(); t.from = b.secret();
} }
if (!t.gasPrice) if (!t.gasPrice)
t.gasPrice = 10 * dev::eth::szabo; t.gasPrice = 10 * dev::eth::szabo;
if (!t.gas) if (!t.gas)
t.gas = min<u256>(client()->gasLimitRemaining(), client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice); t.gas = min<u256>(client()->gasLimitRemaining(), client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice);
if (t.to) if (t.to)
client()->transact(t.from, t.value, t.to, t.data, t.gas, t.gasPrice); client()->transact(t.from, t.value, t.to, t.data, t.gas, t.gasPrice);
else else
ret = toJS(client()->transact(t.from, t.value, t.data, t.gas, t.gasPrice)); ret = toJS(client()->transact(t.from, t.value, t.data, t.gas, t.gasPrice));
client()->flushTransactions(); client()->flushTransactions();
return ret; return ret;
} }
Json::Value EthStubServer::transaction(const int &i, const Json::Value &params) Json::Value EthStubServer::transaction(const int &i, const Json::Value &params)

72
libethrpc/EthStubServer.h

@ -1,19 +1,19 @@
/* /*
This file is part of cpp-ethereum. This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of 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. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file EthStubServer.h /** @file EthStubServer.h
* @authors: * @authors:
* Gav Wood <i@gavwood.com> * Gav Wood <i@gavwood.com>
@ -37,44 +37,44 @@ class EthStubServer: public AbstractEthStubServer
{ {
public: public:
EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::WebThreeDirect& _web3); EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::WebThreeDirect& _web3);
virtual std::string balanceAt(const std::string& address, const int& block); virtual std::string balanceAt(const std::string& address, const int& block);
virtual Json::Value block(const Json::Value& params); virtual Json::Value block(const Json::Value& params);
virtual std::string call(const Json::Value& json); virtual std::string call(const Json::Value& json);
virtual std::string codeAt(const std::string& address, const int& block); virtual std::string codeAt(const std::string& address, const int& block);
virtual std::string coinbase(); virtual std::string coinbase();
virtual double countAt(const std::string& address, const int& block); virtual double countAt(const std::string& address, const int& block);
virtual int defaultBlock(); virtual int defaultBlock();
virtual std::string fromAscii(const int& padding, const std::string& s); virtual std::string fromAscii(const int& padding, const std::string& s);
virtual double fromFixed(const std::string& s); virtual double fromFixed(const std::string& s);
virtual std::string gasPrice(); virtual std::string gasPrice();
virtual bool listening(); virtual bool listening();
virtual bool mining(); virtual bool mining();
virtual std::string key(); virtual std::string key();
virtual Json::Value keys(); virtual Json::Value keys();
virtual std::string lll(const std::string& s); virtual std::string lll(const std::string& s);
virtual Json::Value messages(const Json::Value& json); virtual Json::Value messages(const Json::Value& json);
virtual int number(); virtual int number();
virtual int peerCount(); virtual int peerCount();
virtual std::string secretToAddress(const std::string& s); virtual std::string secretToAddress(const std::string& s);
virtual bool setCoinbase(const std::string& address); virtual bool setCoinbase(const std::string& address);
virtual bool setListening(const bool& listening); virtual bool setListening(const bool& listening);
virtual bool setMining(const bool& mining); virtual bool setMining(const bool& mining);
virtual std::string sha3(const std::string& s); virtual std::string sha3(const std::string& s);
virtual std::string stateAt(const std::string& address, const int& block, const std::string& storage); virtual std::string stateAt(const std::string& address, const int& block, const std::string& storage);
virtual std::string toAscii(const std::string& s); virtual std::string toAscii(const std::string& s);
virtual std::string toDecimal(const std::string& s); virtual std::string toDecimal(const std::string& s);
virtual std::string toFixed(const double& s); virtual std::string toFixed(const double& s);
virtual std::string transact(const Json::Value& json); virtual std::string transact(const Json::Value& json);
virtual Json::Value transaction(const int& i, const Json::Value& params); virtual Json::Value transaction(const int& i, const Json::Value& params);
virtual Json::Value uncle(const int& i, const Json::Value &params); virtual Json::Value uncle(const int& i, const Json::Value &params);
virtual int watch(const std::string& json); virtual int watch(const std::string& json);
virtual bool check(const int& id); virtual bool check(const int& id);
virtual bool killWatch(const int& id); virtual bool killWatch(const int& id);
void setKeys(std::vector<dev::KeyPair> _keys) { m_keys = _keys; } void setKeys(std::vector<dev::KeyPair> _keys) { m_keys = _keys; }
private: private:
dev::eth::Interface* client() const; dev::eth::Interface* client() const;
dev::WebThreeDirect& m_web3; dev::WebThreeDirect& m_web3;
std::vector<dev::KeyPair> m_keys; std::vector<dev::KeyPair> m_keys;
dev::FixedHash<32> numberOrHash(Json::Value const &_json) const; dev::FixedHash<32> numberOrHash(Json::Value const &_json) const;

16
libqethereum/QEthereum.h

@ -279,15 +279,15 @@ private:
frame->addToJavaScriptWindowObject("eth", eth, QWebFrame::ScriptOwnership); \ frame->addToJavaScriptWindowObject("eth", eth, QWebFrame::ScriptOwnership); \
frame->addToJavaScriptWindowObject("shh", eth, QWebFrame::ScriptOwnership); \ frame->addToJavaScriptWindowObject("shh", eth, QWebFrame::ScriptOwnership); \
frame->addToJavaScriptWindowObject("p2p", p2p, QWebFrame::ScriptOwnership); \ frame->addToJavaScriptWindowObject("p2p", p2p, QWebFrame::ScriptOwnership); \
frame->evaluateJavaScript("eth.setCoinbase = function(a, f) { window.setTimeout(function () { eth.coinbase = a; if (f) {f(true);}}, 0); }"); \ frame->evaluateJavaScript("eth.setCoinbase = function(a, f) { window.setTimeout(function () { eth.coinbase = a; if (f) {f(true);}}, 0); }"); \
frame->evaluateJavaScript("eth.getCoinbase = function(f) { window.setTimeout(function () { if (f) {f(eth.coinbase);}}, 0); }"); \ frame->evaluateJavaScript("eth.getCoinbase = function(f) { window.setTimeout(function () { if (f) {f(eth.coinbase);}}, 0); }"); \
frame->evaluateJavaScript("eth.listening = {get listening() {return p2p.listening}, set listening(l) {p2p.listening = l}}"); \ frame->evaluateJavaScript("eth.listening = {get listening() {return p2p.listening}, set listening(l) {p2p.listening = l}}"); \
frame->evaluateJavaScript("eth.setListening = function(a, f) { window.setTimeout(function () { eth.listening = a; if (f) {f(true);}}, 0); }"); \ frame->evaluateJavaScript("eth.setListening = function(a, f) { window.setTimeout(function () { eth.listening = a; if (f) {f(true);}}, 0); }"); \
frame->evaluateJavaScript("eth.getListening = function(f) { window.setTimeout(function () { if (f) {f(eth.listening);}}, 0); }"); \ frame->evaluateJavaScript("eth.getListening = function(f) { window.setTimeout(function () { if (f) {f(eth.listening);}}, 0); }"); \
frame->evaluateJavaScript("eth.setMining = function(a, f) { window.setTimeout(function () { eth.mining = a; if (f) {f(true);}}, 0); }"); \ frame->evaluateJavaScript("eth.setMining = function(a, f) { window.setTimeout(function () { eth.mining = a; if (f) {f(true);}}, 0); }"); \
frame->evaluateJavaScript("eth.getMining = function(f) { window.setTimeout(function () { if (f) { f(eth.mining);}}, 0); }"); \ frame->evaluateJavaScript("eth.getMining = function(f) { window.setTimeout(function () { if (f) { f(eth.mining);}}, 0); }"); \
frame->evaluateJavaScript("eth.getGasPrice = function(f) { window.setTimeout(function () { if (f) {f(eth.gasPrice);}}, 0); }"); \ frame->evaluateJavaScript("eth.getGasPrice = function(f) { window.setTimeout(function () { if (f) {f(eth.gasPrice);}}, 0); }"); \
frame->evaluateJavaScript("eth.getKey = function(f) { window.setTimeout(function () { if(f) {f(eth.key);}}, 0); }"); \ frame->evaluateJavaScript("eth.getKey = function(f) { window.setTimeout(function () { if(f) {f(eth.key);}}, 0); }"); \
frame->evaluateJavaScript("eth.getKeys = function(f) { window.setTimeout(function () { if (f) {f(eth.keys);}}, 0); }"); \ frame->evaluateJavaScript("eth.getKeys = function(f) { window.setTimeout(function () { if (f) {f(eth.keys);}}, 0); }"); \
frame->evaluateJavaScript("eth.peerCount = {get peerCount() {return p2p.peerCount}}"); \ frame->evaluateJavaScript("eth.peerCount = {get peerCount() {return p2p.peerCount}}"); \
frame->evaluateJavaScript("eth.getPeerCount = function(f) { window.setTimeout(function () { if (f) {f(eth.peerCount);}}, 0); }"); \ frame->evaluateJavaScript("eth.getPeerCount = function(f) { window.setTimeout(function () { if (f) {f(eth.peerCount);}}, 0); }"); \

Loading…
Cancel
Save