Browse Source

Renaming and fixes.

cl-refactor
Gav Wood 10 years ago
parent
commit
7a0cb2bf23
  1. 3
      alethzero/MainWin.cpp
  2. 4
      libethereum/BlockChain.h
  3. 12
      libethereum/Client.cpp
  4. 6
      libjsqrc/ethereum.js
  5. 2
      libweb3jsonrpc/WebThreeStubServer.cpp
  6. 2
      libweb3jsonrpc/WebThreeStubServer.h
  7. 8
      libweb3jsonrpc/abstractwebthreestubserver.h
  8. 2
      libweb3jsonrpc/spec.json
  9. 4
      test/webthreestubclient.h
  10. 17
      third/MainWin.cpp
  11. 4
      third/MainWin.h

3
alethzero/MainWin.cpp

@ -1292,7 +1292,7 @@ void Main::on_blocks_currentItemChanged()
Transaction tx(block[1][txi].data());
auto ss = tx.safeSender();
h256 th = sha3(rlpList(ss, tx.nonce()));
auto receipt = ethereum()->blockChain().receipts(h).receipts[txi];
TransactionReceipt receipt = ethereum()->blockChain().receipts(h).receipts[txi];
s << "<h3>" << th << "</h3>";
s << "<h4>" << h << "[<b>" << txi << "</b>]</h4>";
s << "<br/>From: <b>" << pretty(ss).toHtmlEscaped().toStdString() << "</b> " << ss;
@ -1308,6 +1308,7 @@ void Main::on_blocks_currentItemChanged()
s << "<br/>R: <b>" << hex << nouppercase << tx.signature().r << "</b>";
s << "<br/>S: <b>" << hex << nouppercase << tx.signature().s << "</b>";
s << "<br/>Msg: <b>" << tx.sha3(eth::WithoutSignature) << "</b>";
s << "<div>Log Bloom: " << receipt.bloom() << "</div>";
s << "<div>Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(block[1][txi].data()) << "</span></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";

4
libethereum/BlockChain.h

@ -93,6 +93,10 @@ public:
/// Returns true if the given block is known (though not necessarily a part of the canon chain).
bool isKnown(h256 _hash) const;
/// Get the familial details concerning a block (or the most recent mined if none given). Thread-safe.
BlockInfo info(h256 _hash) const { return BlockInfo(block(_hash)); }
BlockInfo info() const { return BlockInfo(block()); }
/// Get the familial details concerning a block (or the most recent mined if none given). Thread-safe.
BlockDetails details(h256 _hash) const { return queryExtras<BlockDetails, 0>(_hash, m_details, x_details, NullBlockDetails); }
BlockDetails details() const { return details(currentHash()); }

12
libethereum/Client.cpp

@ -232,12 +232,12 @@ void Client::appendFromNewPending(LogBloom _bloom, h256Set& o_changed) const
void Client::appendFromNewBlock(h256 _block, h256Set& o_changed) const
{
// auto d = m_bc.info(_block);
//
// lock_guard<mutex> l(m_filterLock);
// for (pair<h256, InstalledFilter> const& i: m_filters)
// if ((unsigned)i.second.filter.latest() >= d.number && (unsigned)i.second.filter.earliest() <= d.number && i.second.filter.matches(d.logBloom))
// o_changed.insert(i.first);
auto d = m_bc.info(_block);
lock_guard<mutex> l(m_filterLock);
for (pair<h256, InstalledFilter> const& i: m_filters)
if ((unsigned)i.second.filter.latest() >= d.number && (unsigned)i.second.filter.earliest() <= d.number && i.second.filter.matches(d.logBloom))
o_changed.insert(i.first);
}
void Client::setForceMining(bool _enable)

6
libjsqrc/ethereum.js

@ -599,7 +599,7 @@ var ethWatchMethods = function () {
return [
{ name: 'newFilter', call: newFilter },
{ name: 'uninstallFilter', call: 'eth_uninstallFilter' },
{ name: 'getMessages', call: 'eth_getMessages' }
{ name: 'logs', call: 'eth_getMessages' }
];
};
@ -904,6 +904,8 @@ Filter.prototype.messages = function() {
});
};
Filter.prototype.logs = Filter.prototype.messages;
function messageHandler(data) {
if(data._event !== undefined) {
web3.trigger(data._event, data._id, data.data);
@ -1060,4 +1062,4 @@ module.exports = web3;
},{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":4,"./lib/main":5,"./lib/qt":6,"./lib/websocket":7}]},{},[])
//# sourceMappingURL=ethereum.js.map
//# sourceMappingURL=ethereum.js.map

2
libweb3jsonrpc/WebThreeStubServer.cpp

@ -394,7 +394,7 @@ std::string WebThreeStubServer::db_get(std::string const& _name, std::string con
return toJS(dev::asBytes(ret));
}
Json::Value WebThreeStubServer::eth_getMessages(int const& _id)
Json::Value WebThreeStubServer::eth_getLogs(int const& _id)
{
if (!client())
return Json::Value();

2
libweb3jsonrpc/WebThreeStubServer.h

@ -76,7 +76,7 @@ public:
virtual double eth_countAt(std::string const& _address);
virtual int eth_defaultBlock();
virtual std::string eth_gasPrice();
virtual Json::Value eth_getMessages(int const& _id);
virtual Json::Value eth_getLogs(int const& _id);
virtual bool eth_listening();
virtual bool eth_mining();
virtual int eth_newFilter(Json::Value const& _json);

8
libweb3jsonrpc/abstractwebthreestubserver.h

@ -29,7 +29,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(new jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_getMessages", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_getMessagesI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_getLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_getLogsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI);
@ -142,9 +142,9 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
response = this->eth_gasPrice();
}
inline virtual void eth_getMessagesI(const Json::Value& request, Json::Value& response)
inline virtual void eth_getLogsI(const Json::Value& request, Json::Value& response)
{
response = this->eth_getMessages(request[0u].asInt());
response = this->eth_getLogs(request[0u].asInt());
}
inline virtual void eth_listeningI(const Json::Value& request, Json::Value& response)
@ -309,7 +309,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual double eth_countAt(const std::string& param1) = 0;
virtual int eth_defaultBlock() = 0;
virtual std::string eth_gasPrice() = 0;
virtual Json::Value eth_getMessages(const int& param1) = 0;
virtual Json::Value eth_getLogs(const int& param1) = 0;
virtual bool eth_listening() = 0;
virtual std::string eth_lll(const std::string& param1) = 0;
virtual bool eth_mining() = 0;

2
libweb3jsonrpc/spec.json

@ -37,7 +37,7 @@
{ "method": "eth_newFilterString", "params": [""], "order": [], "returns": 0},
{ "method": "eth_uninstallFilter", "params": [0], "order": [], "returns": true},
{ "method": "eth_changed", "params": [0], "order": [], "returns": false},
{ "method": "eth_getMessages", "params": [0], "order": [], "returns": []},
{ "method": "eth_getLogs", "params": [0], "order": [], "returns": []},
{ "method": "db_put", "params": ["", "", ""], "order": [], "returns": true},
{ "method": "db_get", "params": ["", ""], "order": [], "returns": ""},

4
test/webthreestubclient.h

@ -228,12 +228,12 @@ p.append(param3);
}
Json::Value eth_getMessages(const int& param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getLogs(const int& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->client->CallMethod("eth_getMessages",p);
Json::Value result = this->client->CallMethod("eth_getLogs",p);
if (result.isArray())
return result;
else

17
third/MainWin.cpp

@ -182,7 +182,7 @@ void Main::onKeysChanged()
installBalancesWatch();
}
unsigned Main::installWatch(dev::eth::MessageFilter const& _tf, std::function<void()> const& _f)
unsigned Main::installWatch(dev::eth::LogFilter const& _tf, std::function<void()> const& _f)
{
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
@ -198,37 +198,34 @@ unsigned Main::installWatch(dev::h256 _tf, std::function<void()> const& _f)
void Main::installWatches()
{
installWatch(dev::eth::MessageFilter().altered(c_config, 0), [=](){ installNameRegWatch(); });
installWatch(dev::eth::MessageFilter().altered(c_config, 1), [=](){ installCurrenciesWatch(); });
installWatch(dev::eth::LogFilter().topic((u256)(u160)c_config).topic((u256)0), [=](){ installNameRegWatch(); });
installWatch(dev::eth::LogFilter().topic((u256)(u160)c_config).topic((u256)1), [=](){ installCurrenciesWatch(); });
installWatch(dev::eth::ChainChangedFilter, [=](){ onNewBlock(); });
}
void Main::installNameRegWatch()
{
ethereum()->uninstallWatch(m_nameRegFilter);
m_nameRegFilter = installWatch(dev::eth::MessageFilter().altered((u160)ethereum()->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
m_nameRegFilter = installWatch(dev::eth::LogFilter().topic(ethereum()->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
}
void Main::installCurrenciesWatch()
{
ethereum()->uninstallWatch(m_currenciesFilter);
m_currenciesFilter = installWatch(dev::eth::MessageFilter().altered((u160)ethereum()->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
m_currenciesFilter = installWatch(dev::eth::LogFilter().topic(ethereum()->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
}
void Main::installBalancesWatch()
{
dev::eth::MessageFilter tf;
dev::eth::LogFilter tf;
vector<Address> altCoins;
Address coinsAddr = right160(ethereum()->stateAt(c_config, 1));
for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i)
altCoins.push_back(right160(ethereum()->stateAt(coinsAddr, i + 1)));
for (auto i: m_myKeys)
{
tf.altered(i.address());
for (auto c: altCoins)
tf.altered(c, (u160)i.address());
}
tf.address(c).topic((u256)(u160)i.address());
ethereum()->uninstallWatch(m_balancesFilter);
m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); });

4
third/MainWin.h

@ -40,7 +40,7 @@ namespace dev { class WebThreeDirect;
namespace eth {
class Client;
class State;
class MessageFilter;
class LogFilter;
}
namespace shh {
class WhisperHost;
@ -95,7 +95,7 @@ private:
void readSettings(bool _skipGeometry = false);
void writeSettings();
unsigned installWatch(dev::eth::MessageFilter const& _tf, std::function<void()> const& _f);
unsigned installWatch(dev::eth::LogFilter const& _tf, std::function<void()> const& _f);
unsigned installWatch(dev::h256 _tf, std::function<void()> const& _f);
void onNewBlock();

Loading…
Cancel
Save