diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 117d500cc..c8ca7bb90 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -19,6 +19,7 @@ * @date 2014 */ +#include "MainWin.h" #include #include #include @@ -51,7 +52,6 @@ #include "DownloadView.h" #include "MiningView.h" #include "BuildInfo.h" -#include "MainWin.h" #include "OurWebThreeStubServer.h" #include "ui_Main.h" using namespace std; @@ -66,11 +66,11 @@ static void initUnits(QComboBox* _b) _b->addItem(QString::fromStdString(units()[n].second), n); } -QString Main::fromRaw(dev::h256 _n, unsigned* _inc) +QString Main::fromRaw(h256 _n, unsigned* _inc) { if (_n) { - std::string s((char const*)_n.data(), 32); + string s((char const*)_n.data(), 32); auto l = s.find_first_of('\0'); if (!l) return QString(); @@ -91,13 +91,13 @@ QString Main::fromRaw(dev::h256 _n, unsigned* _inc) return QString(); } -static std::vector keysAsVector(QList const& keys) +static vector keysAsVector(QList const& keys) { auto list = keys.toStdList(); return {begin(list), end(list)}; } -static QString contentsOfQResource(std::string const& res) +static QString contentsOfQResource(string const& res) { QFile file(QString::fromStdString(res)); if (!file.open(QFile::ReadOnly)) @@ -116,7 +116,7 @@ Main::Main(QWidget *parent) : { setWindowFlags(Qt::Window); ui->setupUi(this); - g_logPost = [=](std::string const& s, char const* c) + g_logPost = [=](string const& s, char const* c) { simpleDebugOut(s, c); m_logLock.lock(); @@ -136,8 +136,8 @@ Main::Main(QWidget *parent) : cerr << "Block Hash: " << BlockChain::genesis().hash << endl; cerr << "Block RLP: " << RLP(block) << endl; cerr << "Block Hex: " << toHex(block) << endl; - cerr << "Network protocol version: " << dev::eth::c_protocolVersion << endl; - cerr << "Client database version: " << dev::eth::c_databaseVersion << endl; + cerr << "Network protocol version: " << c_protocolVersion << endl; + cerr << "Client database version: " << c_databaseVersion << endl; ui->configDock->close(); on_verbosity_valueChanged(); @@ -234,7 +234,7 @@ void Main::addNewId(QString _ids) refreshWhisper(); } -dev::p2p::NetworkPreferences Main::netPrefs() const +NetworkPreferences Main::netPrefs() const { return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked()); } @@ -244,7 +244,7 @@ void Main::onKeysChanged() installBalancesWatch(); } -unsigned Main::installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f) +unsigned Main::installWatch(LogFilter const& _tf, WatchHandler const& _f) { auto ret = ethereum()->installWatch(_tf); m_handlers[ret] = _f; @@ -266,10 +266,10 @@ void Main::uninstallWatch(unsigned _w) void Main::installWatches() { - installWatch(dev::eth::LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installNameRegWatch(); }); - installWatch(dev::eth::LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installCurrenciesWatch(); }); - installWatch(dev::eth::PendingChangedFilter, [=](LocalisedLogEntries const&){ onNewPending(); }); - installWatch(dev::eth::ChainChangedFilter, [=](LocalisedLogEntries const&){ onNewBlock(); }); + installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installNameRegWatch(); }); + installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installCurrenciesWatch(); }); + installWatch(PendingChangedFilter, [=](LocalisedLogEntries const&){ onNewPending(); }); + installWatch(ChainChangedFilter, [=](LocalisedLogEntries const&){ onNewBlock(); }); } Address Main::getNameReg() const @@ -285,18 +285,18 @@ Address Main::getCurrencies() const void Main::installNameRegWatch() { uninstallWatch(m_nameRegFilter); - m_nameRegFilter = installWatch(dev::eth::LogFilter().address((u160)getNameReg()), [=](LocalisedLogEntries const&){ onNameRegChange(); }); + m_nameRegFilter = installWatch(LogFilter().address((u160)getNameReg()), [=](LocalisedLogEntries const&){ onNameRegChange(); }); } void Main::installCurrenciesWatch() { uninstallWatch(m_currenciesFilter); - m_currenciesFilter = installWatch(dev::eth::LogFilter().address((u160)getCurrencies()), [=](LocalisedLogEntries const&){ onCurrenciesChange(); }); + m_currenciesFilter = installWatch(LogFilter().address((u160)getCurrencies()), [=](LocalisedLogEntries const&){ onCurrenciesChange(); }); } void Main::installBalancesWatch() { - dev::eth::LogFilter tf; + LogFilter tf; vector
altCoins; Address coinsAddr = getCurrencies(); @@ -467,7 +467,7 @@ static Public stringToPublic(QString const& _a) QString Main::pretty(dev::Address _a) const { -/* static std::map s_memos; +/* static map s_memos; if (!s_memos.count(_a)) {*/ @@ -505,7 +505,7 @@ QString Main::render(dev::Address _a) const return QString::fromStdString(_a.abridged()); } -string32 fromString(std::string const& _s) +string32 fromString(string const& _s) { string32 ret; for (unsigned i = 0; i < 32 && i <= _s.size(); ++i) @@ -518,7 +518,7 @@ Address Main::fromString(QString const& _n) const if (_n == "(Create Contract)") return Address(); -/* static std::map s_memos; +/* static map s_memos; if (!s_memos.count(_n)) {*/ @@ -860,18 +860,18 @@ void Main::on_preview_triggered() void Main::refreshMining() { - dev::eth::MineProgress p = ethereum()->miningProgress(); + MineProgress p = ethereum()->miningProgress(); ui->mineStatus->setText(ethereum()->isMining() ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Not mining"); if (!ui->miningView->isVisible()) return; - list l = ethereum()->miningHistory(); + list l = ethereum()->miningHistory(); static unsigned lh = 0; if (p.hashes < lh) ui->miningView->resetStats(); lh = p.hashes; ui->miningView->appendStats(l, p); /* if (p.ms) - for (dev::eth::MineInfo const& i: l) + for (MineInfo const& i: l) cnote << i.hashes * 10 << "h/sec, need:" << i.requirement << " best:" << i.best << " best-so-far:" << p.best << " avg-speed:" << (p.hashes * 1000 / p.ms) << "h/sec"; */ } @@ -1026,10 +1026,10 @@ void Main::refreshBlockCount() cwatch << "refreshBlockCount()"; auto d = ethereum()->blockChain().details(); auto diff = BlockInfo(ethereum()->blockChain().block()).difficulty; - ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(dev::eth::c_protocolVersion).arg(dev::eth::c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet")); + ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet")); } -static bool blockMatch(string const& _f, dev::eth::BlockDetails const& _b, h256 _h, BlockChain const& _bc) +static bool blockMatch(string const& _f, BlockDetails const& _b, h256 _h, BlockChain const& _bc) { try { @@ -1178,7 +1178,7 @@ void Main::timerEvent(QTimerEvent*) } } -string Main::renderDiff(dev::eth::StateDiff const& _d) const +string Main::renderDiff(StateDiff const& _d) const { stringstream s; @@ -1187,24 +1187,24 @@ string Main::renderDiff(dev::eth::StateDiff const& _d) const { s << "
"; - dev::eth::AccountDiff const& ad = i.second; + AccountDiff const& ad = i.second; s << "" << lead(ad.changeType()) << " " << " " << render(i.first).toStdString() << ""; if (!ad.exist.to()) continue; if (ad.balance) { - s << "
" << indent << "Balance " << std::dec << formatBalance(ad.balance.to()); - s << " " << std::showpos << (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())) << std::noshowpos << ""; + s << "
" << indent << "Balance " << dec << formatBalance(ad.balance.to()); + s << " " << showpos << (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())) << noshowpos << ""; } if (ad.nonce) { - s << "
" << indent << "Count #" << std::dec << ad.nonce.to(); - s << " " << std::showpos << (((dev::bigint)ad.nonce.to()) - ((dev::bigint)ad.nonce.from())) << std::noshowpos << ""; + s << "
" << indent << "Count #" << dec << ad.nonce.to(); + s << " " << showpos << (((dev::bigint)ad.nonce.to()) - ((dev::bigint)ad.nonce.from())) << noshowpos << ""; } if (ad.code) { - s << "
" << indent << "Code " << std::hex << ad.code.to().size() << " bytes"; + s << "
" << indent << "Code " << hex << ad.code.to().size() << " bytes"; if (ad.code.from().size()) s << " (" << ad.code.from().size() << " bytes)"; } @@ -1226,7 +1226,7 @@ string Main::renderDiff(dev::eth::StateDiff const& _d) const else if (i.first > u160(1) << 150) s << (h160)(u160)i.first; else - s << std::hex << i.first; + s << hex << i.first; */ if (!i.second.from()) s << ": " << prettyU256(i.second.to()).toStdString(); @@ -1479,10 +1479,10 @@ void Main::populateDebugger(dev::bytesConstRef _r) bytesConstRef lastData; h256 lastHash; h256 lastDataHash; - auto onOp = [&](uint64_t steps, Instruction inst, dev::bigint newMemSize, dev::bigint gasCost, dev::eth::VM* voidVM, dev::eth::ExtVMFace const* voidExt) + auto onOp = [&](uint64_t steps, Instruction inst, dev::bigint newMemSize, dev::bigint gasCost, VM* voidVM, ExtVMFace const* voidExt) { - dev::eth::VM& vm = *voidVM; - dev::eth::ExtVM const& ext = *static_cast(voidExt); + VM& vm = *voidVM; + ExtVM const& ext = *static_cast(voidExt); if (ext.code != lastExtCode) { lastExtCode = ext.code; @@ -1605,11 +1605,11 @@ static shh::Topic topicFromText(QString _s) { u256 v(d.cap(2).toStdString()); if (d.cap(6) == "szabo") - v *= dev::eth::szabo; + v *= szabo; else if (d.cap(5) == "finney") - v *= dev::eth::finney; + v *= finney; else if (d.cap(4) == "ether") - v *= dev::eth::ether; + v *= ether; bytes bs = dev::toCompactBigEndian(v); if (d.cap(1) != "$") for (auto i = bs.size(); i < 32; ++i) @@ -1636,7 +1636,7 @@ static shh::Topic topicFromText(QString _s) } -bool Main::sourceIsSolidity(std::string const& _source) +bool Main::sourceIsSolidity(string const& _source) { // TODO: Improve this heuristic return (_source.substr(0, 8) == "contract" || _source.substr(0, 5) == "//sol"); @@ -1695,7 +1695,7 @@ void Main::on_data_textChanged() } else { - m_data = dev::eth::compileLLL(src, m_enableOptimizer, &errors); + m_data = compileLLL(src, m_enableOptimizer, &errors); if (errors.size()) { try @@ -1711,11 +1711,11 @@ void Main::on_data_textChanged() } else { - auto asmcode = dev::eth::compileLLLToAsm(src, false); + auto asmcode = compileLLLToAsm(src, false); lll = "

Pre

" + QString::fromStdString(asmcode).toHtmlEscaped() + "
"; if (m_enableOptimizer) { - asmcode = dev::eth::compileLLLToAsm(src, true); + asmcode = compileLLLToAsm(src, true); lll = "

Opt

" + QString::fromStdString(asmcode).toHtmlEscaped() + "
" + lll; } } @@ -1906,7 +1906,7 @@ void Main::on_send_clicked() { dev::solidity::CompilerStack compiler; m_data = compiler.compile(src, m_enableOptimizer); - for (std::string& s: compiler.getContractNames()) + for (string& s: compiler.getContractNames()) { h256 contractHash = compiler.getContractCodeHash(s); m_natspecDB.add(contractHash, @@ -2053,7 +2053,7 @@ void Main::on_dumpTracePretty_triggered() f << " STORAGE" << endl; for (auto const& i: ws.storage) f << showbase << hex << i.first << ": " << i.second << endl; - f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32"; + f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32"; } } @@ -2280,7 +2280,7 @@ void Main::updateDebugger() cwarn << "PC (" << (unsigned)ws.curPC << ") is after code range (" << m_codes[ws.code].size() << ")"; ostringstream ss; - ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas; + ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas; ui->debugStateInfo->setText(QString::fromStdString(ss.str())); stringstream s; for (auto const& i: ws.storage) @@ -2302,12 +2302,12 @@ void Main::on_post_clicked() whisper()->inject(m.seal(from, topicFromText(ui->shhTopic->toPlainText()), ui->shhTtl->value(), ui->shhWork->value())); } -std::string Main::lookupNatSpec(dev::h256 const& _contractHash) const +string Main::lookupNatSpec(dev::h256 const& _contractHash) const { return m_natspecDB.retrieve(_contractHash); } -std::string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData) +string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData) { return m_natspecDB.getUserNotice(_contractHash, _transactionData); }