Browse Source

Moving over to use WebThree.

cl-refactor
Gav Wood 10 years ago
parent
commit
1accc20d21
  1. 2
      alethzero/CMakeLists.txt
  2. 210
      alethzero/MainWin.cpp
  3. 7
      alethzero/MainWin.h
  4. 3
      libdevcrypto/FileSystem.cpp
  5. 3
      libdevcrypto/FileSystem.h
  6. 2
      libethcore/BlockInfo.h
  7. 5
      libethereum/Client.cpp
  8. 7
      libethereum/Client.h
  9. 5
      libethereum/Interface.h
  10. 53
      libqethereum/QEthereum.cpp
  11. 11
      libqethereum/QEthereum.h
  12. 8
      libwebthree/WebThree.h
  13. 2
      walleth/MainWin.cpp

2
alethzero/CMakeLists.txt

@ -52,7 +52,7 @@ else ()
endif ()
qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)
target_link_libraries(${EXECUTEABLE} qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore)
target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore)
if (APPLE)
# First have qt5 install plugins and frameworks

210
alethzero/MainWin.cpp

@ -30,6 +30,7 @@
#include <boost/algorithm/string.hpp>
#include <libserpent/funcs.h>
#include <libserpent/util.h>
#include <libdevcrypto/FileSystem.h>
#include <libethcore/Dagger.h>
#include <liblll/Compiler.h>
#include <liblll/CodeFragment.h>
@ -43,45 +44,9 @@
#include "MainWin.h"
#include "ui_Main.h"
using namespace std;
// types
using dev::bytes;
using dev::bytesConstRef;
using dev::h160;
using dev::h256;
using dev::u160;
using dev::u256;
using dev::Address;
using dev::eth::BlockInfo;
using dev::eth::Client;
using dev::eth::Instruction;
using dev::KeyPair;
using dev::eth::NodeMode;
using dev::eth::BlockChain;
using dev::p2p::PeerInfo;
using dev::RLP;
using dev::Secret;
using dev::eth::Transaction;
using dev::eth::Executive;
// functions
using dev::toHex;
using dev::fromHex;
using dev::left160;
using dev::right160;
using dev::simpleDebugOut;
using dev::toLog2;
using dev::toString;
using dev::operator<<;
using dev::eth::units;
using dev::eth::sha3;
using dev::eth::compileLLL;
using dev::eth::disassemble;
using dev::eth::formatBalance;
// vars
using dev::g_logPost;
using dev::g_logVerbosity;
using namespace dev;
using namespace dev::p2p;
using namespace dev::eth;
static void initUnits(QComboBox* _b)
{
@ -177,12 +142,12 @@ Main::Main(QWidget *parent) :
connect(ui->ourAccounts->model(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(ourAccountsRowsMoved()));
m_client.reset(new Client("AlethZero"));
m_webThree.reset(new WebThreeDirect("AlethZero", getDataDir() + "/AlethZero", false));
connect(ui->webView, &QWebView::loadStarted, [this]()
{
// NOTE: no need to delete as QETH_INSTALL_JS_NAMESPACE adopts it.
m_ethereum = new QEthereum(this, client(), owned());
m_ethereum = new QEthereum(this, ethereum(), owned());
QWebFrame* f = ui->webView->page()->mainFrame();
f->disconnect(SIGNAL(javaScriptWindowObjectCleared()));
@ -233,14 +198,14 @@ void Main::onKeysChanged()
unsigned Main::installWatch(dev::eth::MessageFilter const& _tf, std::function<void()> const& _f)
{
auto ret = client()->installWatch(_tf);
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
return ret;
}
unsigned Main::installWatch(dev::h256 _tf, std::function<void()> const& _f)
{
auto ret = client()->installWatch(_tf);
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
return ret;
}
@ -255,14 +220,14 @@ void Main::installWatches()
void Main::installNameRegWatch()
{
client()->uninstallWatch(m_nameRegFilter);
m_nameRegFilter = installWatch(dev::eth::MessageFilter().altered((u160)client()->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
ethereum()->uninstallWatch(m_nameRegFilter);
m_nameRegFilter = installWatch(dev::eth::MessageFilter().altered((u160)ethereum()->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
}
void Main::installCurrenciesWatch()
{
client()->uninstallWatch(m_currenciesFilter);
m_currenciesFilter = installWatch(dev::eth::MessageFilter().altered((u160)client()->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
ethereum()->uninstallWatch(m_currenciesFilter);
m_currenciesFilter = installWatch(dev::eth::MessageFilter().altered((u160)ethereum()->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
}
void Main::installBalancesWatch()
@ -270,9 +235,9 @@ void Main::installBalancesWatch()
dev::eth::MessageFilter tf;
vector<Address> altCoins;
Address coinsAddr = right160(client()->stateAt(c_config, 1));
for (unsigned i = 0; i < client()->stateAt(coinsAddr, 0); ++i)
altCoins.push_back(right160(client()->stateAt(coinsAddr, i + 1)));
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());
@ -280,7 +245,7 @@ void Main::installBalancesWatch()
tf.altered(c, (u160)i.address());
}
client()->uninstallWatch(m_balancesFilter);
ethereum()->uninstallWatch(m_balancesFilter);
m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); });
}
@ -328,7 +293,7 @@ void Main::onNewPending()
void Main::on_forceMining_triggered()
{
client()->setForceMining(ui->forceMining->isChecked());
ethereum()->setForceMining(ui->forceMining->isChecked());
}
void Main::on_enableOptimizer_triggered()
@ -422,11 +387,11 @@ QString Main::pretty(dev::Address _a) const
{
h256 n;
if (h160 nameReg = (u160)client()->stateAt(c_config, 0))
n = client()->stateAt(nameReg, (u160)(_a));
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0))
n = ethereum()->stateAt(nameReg, (u160)(_a));
if (!n)
n = client()->stateAt(m_nameReg, (u160)(_a));
n = ethereum()->stateAt(m_nameReg, (u160)(_a));
return fromRaw(n);
}
@ -452,11 +417,11 @@ Address Main::fromString(QString const& _a) const
memset(n.data() + sn.size(), 0, 32 - sn.size());
if (_a.size())
{
if (h160 nameReg = (u160)client()->stateAt(c_config, 0))
if (h256 a = client()->stateAt(nameReg, n))
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0))
if (h256 a = ethereum()->stateAt(nameReg, n))
return right160(a);
if (h256 a = client()->stateAt(m_nameReg, n))
if (h256 a = ethereum()->stateAt(m_nameReg, n))
return right160(a);
}
if (_a.size() == 40)
@ -484,11 +449,11 @@ QString Main::lookup(QString const& _a) const
*/
h256 ret;
if (h160 dnsReg = (u160)client()->stateAt(c_config, 4, 0))
ret = client()->stateAt(dnsReg, n);
if (h160 dnsReg = (u160)ethereum()->stateAt(c_config, 4, 0))
ret = ethereum()->stateAt(dnsReg, n);
/* if (!ret)
if (h160 nameReg = (u160)m_client->stateAt(c_config, 0, 0))
ret = m_client->stateAt(nameReg, n2);
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0, 0))
ret = ethereum()->stateAt(nameReg, n2);
*/
if (ret && !((u256)ret >> 32))
return QString("%1.%2.%3.%4").arg((int)ret[28]).arg((int)ret[29]).arg((int)ret[30]).arg((int)ret[31]);
@ -506,7 +471,7 @@ void Main::on_about_triggered()
void Main::on_paranoia_triggered()
{
client()->setParanoia(ui->paranoia->isChecked());
ethereum()->setParanoia(ui->paranoia->isChecked());
}
void Main::writeSettings()
@ -537,7 +502,7 @@ void Main::writeSettings()
s.setValue("privateChain", m_privateChain);
s.setValue("verbosity", ui->verbosity->value());
bytes d = client()->savePeers();
bytes d = ethereum()->savePeers();
if (d.size())
m_peers = QByteArray((char*)d.data(), (int)d.size());
s.setValue("peers", m_peers);
@ -569,7 +534,7 @@ void Main::readSettings(bool _skipGeometry)
m_myKeys.append(KeyPair(k));
}
}
client()->setAddress(m_myKeys.back().address());
ethereum()->setAddress(m_myKeys.back().address());
m_peers = s.value("peers").toByteArray();
ui->upnp->setChecked(s.value("upnp", true).toBool());
ui->forceAddress->setText(s.value("forceAddress", "").toString());
@ -665,17 +630,17 @@ void Main::on_nameReg_textChanged()
void Main::on_preview_triggered()
{
client()->setDefault(ui->preview->isChecked() ? 0 : -1);
ethereum()->setDefault(ui->preview->isChecked() ? 0 : -1);
refreshAll();
}
void Main::refreshMining()
{
dev::eth::MineProgress p = client()->miningProgress();
ui->mineStatus->setText(client()->isMining() ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Not mining");
dev::eth::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<dev::eth::MineInfo> l = client()->miningHistory();
list<dev::eth::MineInfo> l = ethereum()->miningHistory();
static unsigned lh = 0;
if (p.hashes < lh)
ui->miningView->resetStats();
@ -694,12 +659,12 @@ void Main::refreshBalances()
ui->ourAccounts->clear();
u256 totalBalance = 0;
map<Address, tuple<QString, u256, u256>> altCoins;
Address coinsAddr = right160(client()->stateAt(c_config, 1));
for (unsigned i = 0; i < client()->stateAt(coinsAddr, 0); ++i)
Address coinsAddr = right160(ethereum()->stateAt(c_config, 1));
for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i)
{
auto n = client()->stateAt(coinsAddr, i + 1);
auto addr = right160(client()->stateAt(coinsAddr, n));
auto denom = client()->stateAt(coinsAddr, sha3(h256(n).asBytes()));
auto n = ethereum()->stateAt(coinsAddr, i + 1);
auto addr = right160(ethereum()->stateAt(coinsAddr, n));
auto denom = ethereum()->stateAt(coinsAddr, sha3(h256(n).asBytes()));
if (denom == 0)
denom = 1;
// cdebug << n << addr << denom << sha3(h256(n).asBytes());
@ -707,13 +672,13 @@ void Main::refreshBalances()
}
for (auto i: m_myKeys)
{
u256 b = client()->balanceAt(i.address());
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(b).c_str()).arg(render(i.address())).arg((unsigned)client()->countAt(i.address())), ui->ourAccounts))
u256 b = ethereum()->balanceAt(i.address());
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(b).c_str()).arg(render(i.address())).arg((unsigned)ethereum()->countAt(i.address())), ui->ourAccounts))
->setData(Qt::UserRole, QByteArray((char const*)i.address().data(), Address::size));
totalBalance += b;
for (auto& c: altCoins)
get<1>(c.second) += (u256)client()->stateAt(c.first, (u160)i.address());
get<1>(c.second) += (u256)ethereum()->stateAt(c.first, (u160)i.address());
}
QString b;
@ -729,7 +694,7 @@ void Main::refreshBalances()
void Main::refreshNetwork()
{
auto ps = client()->peers();
auto ps = web3()->peers();
ui->peerCount->setText(QString::fromStdString(toString(ps.size())) + " peer(s)");
ui->peers->clear();
@ -751,7 +716,7 @@ void Main::refreshPending()
{
cwatch << "refreshPending()";
ui->transactionQueue->clear();
for (Transaction const& t: client()->pending())
for (Transaction const& t: ethereum()->pending())
{
QString s = t.receiveAddress ?
QString("%2 %5> %3: %1 [%4]")
@ -759,7 +724,7 @@ void Main::refreshPending()
.arg(render(t.safeSender()))
.arg(render(t.receiveAddress))
.arg((unsigned)t.nonce)
.arg(client()->codeAt(t.receiveAddress).size() ? '*' : '-') :
.arg(ethereum()->codeAt(t.receiveAddress).size() ? '*' : '-') :
QString("%2 +> %3: %1 [%4]")
.arg(formatBalance(t.value).c_str())
.arg(render(t.safeSender()))
@ -775,16 +740,16 @@ void Main::refreshAccounts()
ui->accounts->clear();
ui->contracts->clear();
for (auto n = 0; n < 2; ++n)
for (auto i: client()->addresses())
for (auto i: ethereum()->addresses())
{
auto r = render(i);
if (r.contains('(') == !n)
{
if (n == 0 || ui->showAllAccounts->isChecked())
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(client()->balanceAt(i)).c_str()).arg(r).arg((unsigned)client()->countAt(i)), ui->accounts))
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(ethereum()->balanceAt(i)).c_str()).arg(r).arg((unsigned)ethereum()->countAt(i)), ui->accounts))
->setData(Qt::UserRole, QByteArray((char const*)i.data(), Address::size));
if (client()->codeAt(i).size())
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(client()->balanceAt(i)).c_str()).arg(r).arg((unsigned)client()->countAt(i)), ui->contracts))
if (ethereum()->codeAt(i).size())
(new QListWidgetItem(QString("%2: %1 [%3]").arg(formatBalance(ethereum()->balanceAt(i)).c_str()).arg(r).arg((unsigned)ethereum()->countAt(i)), ui->contracts))
->setData(Qt::UserRole, QByteArray((char const*)i.data(), Address::size));
}
}
@ -794,7 +759,7 @@ void Main::refreshDestination()
{
cwatch << "refreshDestination()";
QString s;
for (auto i: client()->addresses())
for (auto i: ethereum()->addresses())
if ((s = pretty(i)).size())
// A namereg address
if (ui->destination->findText(s, Qt::MatchExactly | Qt::MatchCaseSensitive) == -1)
@ -807,8 +772,8 @@ void Main::refreshDestination()
void Main::refreshBlockCount()
{
cwatch << "refreshBlockCount()";
auto d = client()->blockChain().details();
auto diff = BlockInfo(client()->blockChain().block()).difficulty;
auto d = ethereum()->blockChain().details();
auto diff = BlockInfo(ethereum()->blockChain().block()).difficulty;
ui->blockCount->setText(QString("%6 #%1 @%3 T%2 N%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"));
}
@ -839,7 +804,7 @@ static bool transactionMatch(string const& _f, Transaction const& _t)
void Main::on_turboMining_triggered()
{
client()->setTurboMining(ui->turboMining->isChecked());
ethereum()->setTurboMining(ui->turboMining->isChecked());
}
void Main::refreshBlockChain()
@ -850,7 +815,7 @@ void Main::refreshBlockChain()
ui->blocks->clear();
string filter = ui->blockChainFilter->text().toLower().toStdString();
auto const& bc = client()->blockChain();
auto const& bc = ethereum()->blockChain();
unsigned i = (ui->showAll->isChecked() || !filter.empty()) ? (unsigned)-1 : 10;
for (auto h = bc.currentHash(); h != bc.genesisHash() && bc.details(h) && i; h = bc.details(h).parent, --i)
{
@ -877,7 +842,7 @@ void Main::refreshBlockChain()
.arg(render(t.safeSender()))
.arg(render(t.receiveAddress))
.arg((unsigned)t.nonce)
.arg(client()->codeAt(t.receiveAddress).size() ? '*' : '-') :
.arg(ethereum()->codeAt(t.receiveAddress).size() ? '*' : '-') :
QString(" %2 +> %3: %1 [%4]")
.arg(formatBalance(t.value).c_str())
.arg(render(t.safeSender()))
@ -948,7 +913,7 @@ void Main::timerEvent(QTimerEvent*)
m_ethereum->poll();
for (auto const& i: m_handlers)
if (client()->checkWatch(i.first))
if (ethereum()->checkWatch(i.first))
i.second();
}
@ -1019,9 +984,9 @@ void Main::on_transactionQueue_currentItemChanged()
stringstream s;
int i = ui->transactionQueue->currentRow();
if (i >= 0 && i < (int)client()->pending().size())
if (i >= 0 && i < (int)ethereum()->pending().size())
{
Transaction tx(client()->pending()[i]);
Transaction tx(ethereum()->pending()[i]);
auto ss = tx.safeSender();
h256 th = sha3(rlpList(ss, tx.nonce));
s << "<h3>" << th << "</h3>";
@ -1049,7 +1014,7 @@ void Main::on_transactionQueue_currentItemChanged()
// s << "Pre: " << fs.rootHash() << "<br/>";
// s << "Post: <b>" << ts.rootHash() << "</b>";
s << renderDiff(client()->diff(i, 0));
s << renderDiff(ethereum()->diff(i, 0));
}
ui->pendingInfo->setHtml(QString::fromStdString(s.str()));
@ -1076,7 +1041,7 @@ void Main::on_inject_triggered()
{
QString s = QInputDialog::getText(this, "Inject Transaction", "Enter transaction dump in hex");
bytes b = fromHex(s.toStdString());
client()->inject(&b);
ethereum()->inject(&b);
}
void Main::on_blocks_currentItemChanged()
@ -1090,8 +1055,8 @@ void Main::on_blocks_currentItemChanged()
auto hba = item->data(Qt::UserRole).toByteArray();
assert(hba.size() == 32);
auto h = h256((byte const*)hba.data(), h256::ConstructFromPointer);
auto details = client()->blockChain().details(h);
auto blockData = client()->blockChain().block(h);
auto details = ethereum()->blockChain().details(h);
auto blockData = ethereum()->blockChain().block(h);
auto block = RLP(blockData);
BlockInfo info(blockData);
@ -1115,7 +1080,7 @@ void Main::on_blocks_currentItemChanged()
s << "<br/>Bloom: <b>" << details.bloom << "</b>";
s << "<br/>Transactions: <b>" << block[1].itemCount() << "</b> @<b>" << info.transactionsRoot << "</b>";
s << "<br/>Uncles: <b>" << block[2].itemCount() << "</b> @<b>" << info.sha3Uncles << "</b>";
s << "<br/>Pre: <b>" << BlockInfo(client()->blockChain().block(info.parentHash)).stateRoot << "</b>";
s << "<br/>Pre: <b>" << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "</b>";
for (auto const& i: block[1])
s << "<br/>" << sha3(i[0].data()).abridged() << ": <b>" << i[1].toHash<h256>() << "</b> [<b>" << i[2].toInt<u256>() << "</b> used]";
s << "<br/>Post: <b>" << info.stateRoot << "</b>";
@ -1151,7 +1116,7 @@ void Main::on_blocks_currentItemChanged()
if (tx.data.size())
s << dev::memDump(tx.data, 16, true);
}
s << renderDiff(client()->diff(txi, h));
s << renderDiff(ethereum()->diff(txi, h));
ui->debugCurrent->setEnabled(true);
ui->debugDumpState->setEnabled(true);
ui->debugDumpStatePre->setEnabled(true);
@ -1173,7 +1138,7 @@ void Main::on_debugCurrent_triggered()
if (!item->data(Qt::UserRole + 1).isNull())
{
unsigned txi = item->data(Qt::UserRole + 1).toInt();
m_executiveState = client()->state(txi + 1, h);
m_executiveState = ethereum()->state(txi + 1, h);
m_currentExecution = unique_ptr<Executive>(new Executive(m_executiveState));
Transaction t = m_executiveState.pending()[txi];
m_executiveState = m_executiveState.fromPending(txi);
@ -1199,7 +1164,7 @@ void Main::on_debugDumpState_triggered(int _add)
if (f.is_open())
{
unsigned txi = item->data(Qt::UserRole + 1).toInt();
f << client()->state(txi + _add, h) << endl;
f << ethereum()->state(txi + _add, h) << endl;
}
}
}
@ -1265,10 +1230,10 @@ void Main::on_contracts_currentItemChanged()
stringstream s;
try
{
auto storage = client()->storageAt(address);
auto storage = ethereum()->storageAt(address);
for (auto const& i: storage)
s << "@" << showbase << hex << prettyU256(i.first).toStdString() << "&nbsp;&nbsp;&nbsp;&nbsp;" << showbase << hex << prettyU256(i.second).toStdString() << "<br/>";
s << "<h4>Body Code</h4>" << disassemble(client()->codeAt(address));
s << "<h4>Body Code</h4>" << disassemble(ethereum()->codeAt(address));
ui->contractInfo->appendHtml(QString::fromStdString(s.str()));
}
catch (dev::eth::InvalidTrie)
@ -1281,7 +1246,7 @@ void Main::on_contracts_currentItemChanged()
void Main::on_idealPeers_valueChanged()
{
client()->setIdealPeerCount(ui->idealPeers->value());
ethereum()->setIdealPeerCount(ui->idealPeers->value());
}
void Main::on_ourAccounts_doubleClicked()
@ -1427,7 +1392,7 @@ void Main::on_data_textChanged()
s = s.mid(1);
}
ui->code->setHtml(QString::fromStdString(dev::memDump(m_data, 8, true)));
if (client()->codeAt(fromString(ui->destination->currentText()), 0).size())
if (ethereum()->codeAt(fromString(ui->destination->currentText()), 0).size())
{
ui->gas->setMinimum((qint64)Client::txGas(m_data.size(), 1));
if (!ui->gas->isEnabled())
@ -1450,9 +1415,8 @@ void Main::on_killBlockchain_triggered()
writeSettings();
ui->mine->setChecked(false);
ui->net->setChecked(false);
m_client.reset();
m_client.reset(new Client("AlethZero", Address(), string(), true));
m_ethereum->setClient(client());
ethereum()->killChain();
m_ethereum->setClient(ethereum());
readSettings(true);
installWatches();
refreshAll();
@ -1495,7 +1459,7 @@ void Main::updateFee()
bool ok = false;
for (auto i: m_myKeys)
if (client()->balanceAt(i.address()) >= totalReq)
if (ethereum()->balanceAt(i.address()) >= totalReq)
{
ok = true;
break;
@ -1514,15 +1478,17 @@ void Main::on_net_triggered()
if (ui->clientName->text().size())
n += "/" + ui->clientName->text().toStdString();
n += "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM);
client()->setClientVersion(n);
web3()->setClientVersion(n);
if (ui->net->isChecked())
{
client()->startNetwork(ui->port->value(), string(), 0, NodeMode::Full, ui->idealPeers->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), m_privateChain.size() ? sha3(m_privateChain.toStdString()) : 0);
// TODO: alter network stuff?
//ui->port->value(), string(), 0, NodeMode::Full, ui->idealPeers->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), m_privateChain.size() ? sha3(m_privateChain.toStdString()) : 0
web3()->startNetwork();
if (m_peers.size() && ui->usePast->isChecked())
client()->restorePeers(bytesConstRef((byte*)m_peers.data(), m_peers.size()));
web3()->restorePeers(bytesConstRef((byte*)m_peers.data(), m_peers.size()));
}
else
client()->stopNetwork();
web3()->stopNetwork();
}
void Main::on_connect_triggered()
@ -1538,7 +1504,7 @@ void Main::on_connect_triggered()
{
string host = s.section(":", 0, 0).toStdString();
unsigned short port = s.section(":", 1).toInt();
client()->connect(host, port);
web3()->connect(host, port);
}
}
@ -1552,25 +1518,25 @@ void Main::on_mine_triggered()
{
if (ui->mine->isChecked())
{
client()->setAddress(m_myKeys.last().address());
client()->startMining();
ethereum()->setAddress(m_myKeys.last().address());
ethereum()->startMining();
}
else
client()->stopMining();
ethereum()->stopMining();
}
void Main::on_send_clicked()
{
u256 totalReq = value() + fee();
for (auto i: m_myKeys)
if (client()->balanceAt(i.address(), 0) >= totalReq)
if (ethereum()->balanceAt(i.address(), 0) >= totalReq)
{
debugFinished();
Secret s = i.secret();
if (isCreation())
client()->transact(s, value(), m_data, ui->gas->value(), gasPrice());
ethereum()->transact(s, value(), m_data, ui->gas->value(), gasPrice());
else
client()->transact(s, value(), fromString(ui->destination->currentText()), m_data, ui->gas->value(), gasPrice());
ethereum()->transact(s, value(), fromString(ui->destination->currentText()), m_data, ui->gas->value(), gasPrice());
return;
}
statusBar()->showMessage("Couldn't make transaction: no single account contains at least the required amount.");
@ -1583,10 +1549,10 @@ void Main::on_debug_clicked()
{
u256 totalReq = value() + fee();
for (auto i: m_myKeys)
if (client()->balanceAt(i.address()) >= totalReq)
if (ethereum()->balanceAt(i.address()) >= totalReq)
{
Secret s = i.secret();
m_executiveState = client()->postState();
m_executiveState = ethereum()->postState();
m_currentExecution = unique_ptr<Executive>(new Executive(m_executiveState));
Transaction t;
t.nonce = m_executiveState.transactionsFrom(dev::toAddress(s));

7
alethzero/MainWin.h

@ -31,6 +31,7 @@
#include <libethcore/CommonEth.h>
#include <libethereum/State.h>
#include <libqethereum/QEthereum.h>
#include <libwebthree/WebThree.h>
namespace Ui {
class Main;
@ -69,7 +70,9 @@ public:
explicit Main(QWidget *parent = 0);
~Main();
dev::eth::Client* client() const { return m_client.get(); }
dev::WebThreeDirect* web3() const { return m_webThree.get(); }
dev::eth::Client* ethereum() const { return m_webThree->ethereum(); }
dev::shh::WhisperHost* whisper() const { return m_webThree->whisper(); }
QList<dev::KeyPair> const& owned() const { return m_myKeys; }
@ -200,7 +203,7 @@ private:
std::unique_ptr<Ui::Main> ui;
std::unique_ptr<dev::eth::Client> m_client;
std::unique_ptr<dev::WebThreeDirect> m_webThree;
std::map<unsigned, std::function<void()>> m_handlers;
unsigned m_nameRegFilter = (unsigned)-1;

3
libdevcrypto/FileSystem.cpp

@ -31,9 +31,8 @@
#include <boost/filesystem.hpp>
using namespace std;
using namespace dev;
using namespace dev::eth;
std::string dev::eth::getDataDir()
std::string dev::getDataDir()
{
#ifdef _WIN32
char path[1024] = "";

3
libdevcrypto/FileSystem.h

@ -27,11 +27,8 @@
namespace dev
{
namespace eth
{
/// @returns the path for user data.
std::string getDataDir();
}
}

2
libethcore/BlockInfo.h

@ -56,7 +56,7 @@ extern u256 c_genesisDifficulty;
struct BlockInfo
{
public:
h256 hash; ///< SHA3 hash of the entire block! Not serialised (the only member not contained in a block header).
h256 hash; ///< SHA3 hash of the block header! Not serialised (the only member not contained in a block header).
h256 parentHash;
h256 sha3Uncles;
Address coinbaseAddress;

5
libethereum/Client.cpp

@ -124,6 +124,11 @@ void Client::flushTransactions()
work();
}
void Client::killChain()
{
// TODO
}
void Client::clearPending()
{
WriteGuard l(x_stateDB);

7
libethereum/Client.h

@ -165,6 +165,9 @@ public:
// [EXTRA API]:
/// @returns the length of the chain.
virtual unsigned number() const { return m_bc.number(); }
/// Get a map containing each of the pending transactions.
/// @TODO: Remove in favour of transactions().
Transactions pending() const { return m_postMine.pending(); }
@ -254,8 +257,12 @@ public:
/// Get and clear the mining history.
std::list<MineInfo> miningHistory();
// Debug stuff:
/// Clears pending transactions. Just for debug use.
void clearPending();
/// Kills the blockchain. Just for debug use.
void killChain();
private:
/// Ensure the worker thread is running. Needed for blockchain maintenance & mining.

5
libethereum/Interface.h

@ -95,8 +95,13 @@ public:
virtual bool peekWatch(unsigned _watchId) const = 0;
virtual bool checkWatch(unsigned _watchId) = 0;
// TODO: Block query API.
// [EXTRA API]:
/// @returns The height of the chain.
virtual unsigned number() const = 0;
/// Get a map containing each of the pending transactions.
/// @TODO: Remove in favour of transactions().
virtual Transactions pending() const = 0;

53
libqethereum/QEthereum.cpp

@ -8,41 +8,8 @@
#include <libethereum/EthereumHost.h>
#include "QEthereum.h"
using namespace std;
// types
using dev::bytes;
using dev::bytesConstRef;
using dev::h160;
using dev::h256;
using dev::u160;
using dev::u256;
using dev::u256s;
using dev::RLP;
using dev::Address;
using dev::eth::BlockInfo;
using dev::eth::Client;
using dev::eth::Instruction;
using dev::KeyPair;
using dev::eth::NodeMode;
using dev::p2p::PeerInfo;
using dev::Secret;
using dev::eth::Transaction;
// functions
using dev::toHex;
using dev::fromHex;
using dev::right160;
using dev::simpleDebugOut;
using dev::toLog2;
using dev::toString;
using dev::operator+;
using dev::eth::disassemble;
using dev::eth::units;
using dev::eth::formatBalance;
// vars
using dev::g_logPost;
using dev::g_logVerbosity;
using namespace dev;
using namespace dev::eth;
dev::bytes toBytes(QString const& _s)
{
@ -89,7 +56,7 @@ QString unpadded(QString _s)
return _s;
}
QEthereum::QEthereum(QObject* _p, Client* _c, QList<dev::KeyPair> _accounts):
QEthereum::QEthereum(QObject* _p, eth::Interface* _c, QList<dev::KeyPair> _accounts):
QObject(_p), m_client(_c), m_accounts(_accounts)
{
// required to prevent crash on osx when performing addto/evaluatejavascript calls
@ -120,7 +87,7 @@ QString QEthereum::secretToAddress(QString _s) const
return toQJS(KeyPair(toSecret(_s)).address());
}
Client* QEthereum::client() const
eth::Interface* QEthereum::client() const
{
return m_client;
}
@ -162,7 +129,7 @@ QString QEthereum::coinbase() const
QString QEthereum::number() const
{
return m_client ? QString::number(client()->blockChain().number() + 1) : "";
return m_client ? QString::number(client()->number() + 1) : "";
}
QString QEthereum::account() const
@ -381,7 +348,7 @@ bool QEthereum::isMining() const
bool QEthereum::isListening() const
{
return m_client ? client()->haveNetwork() : false;
return /*m_client ? client()->haveNetwork() :*/ false;
}
void QEthereum::setMining(bool _l)
@ -395,19 +362,19 @@ void QEthereum::setMining(bool _l)
}
}
void QEthereum::setListening(bool _l)
void QEthereum::setListening(bool)
{
if (!m_client)
return;
if (_l)
/* if (_l)
client()->startNetwork();
else
client()->stopNetwork();
client()->stopNetwork();*/
}
unsigned QEthereum::peerCount() const
{
return m_client ? (unsigned)client()->peerCount() : 0;
return /*m_client ? (unsigned)client()->peerCount() :*/ 0;
}
QString QEthereum::doCreate(QString _secret, QString _amount, QString _init, QString _gas, QString _gasPrice)

11
libqethereum/QEthereum.h

@ -7,8 +7,7 @@
#include <libethcore/CommonEth.h>
namespace dev { namespace eth {
class Client;
class State;
class Interface;
}}
class QJSEngine;
@ -99,11 +98,11 @@ class QEthereum: public QObject
Q_OBJECT
public:
QEthereum(QObject* _p, dev::eth::Client* _c, QList<dev::KeyPair> _accounts);
QEthereum(QObject* _p, dev::eth::Interface* _c, QList<dev::KeyPair> _accounts);
virtual ~QEthereum();
dev::eth::Client* client() const;
void setClient(dev::eth::Client* _c) { m_client = _c; }
dev::eth::Interface* client() const;
void setClient(dev::eth::Interface* _c) { m_client = _c; }
/// Call when the client() is going to be deleted to make this object useless but safe.
void clientDieing();
@ -199,7 +198,7 @@ private:
Q_PROPERTY(unsigned peerCount READ peerCount NOTIFY miningChanged)
Q_PROPERTY(int defaultBlock READ getDefault WRITE setDefault)
dev::eth::Client* m_client;
dev::eth::Interface* m_client;
std::vector<unsigned> m_watches;
QList<dev::KeyPair> m_accounts;
};

8
libwebthree/WebThree.h

@ -137,7 +137,7 @@ class RPCMaster {};
class EthereumSlave: public eth::Interface
{
public:
EthereumSlave(RPCSlave* _c) {}
EthereumSlave(RPCSlave*) {}
// TODO: implement all of the virtuals with the RLPClient link.
};
@ -145,7 +145,7 @@ public:
class EthereumMaster
{
public:
EthereumMaster(RPCMaster* _m) {}
EthereumMaster(RPCMaster*) {}
// TODO: implement the master-end of whatever the RLPClient link will send over.
};
@ -155,7 +155,7 @@ public:
class WhisperSlave: public shh::Interface
{
public:
WhisperSlave(RPCSlave* _c) {}
WhisperSlave(RPCSlave*) {}
// TODO: implement all of the virtuals with the RLPClient link.
};
@ -163,7 +163,7 @@ public:
class WhisperMaster
{
public:
WhisperMaster(RPCMaster* _m) {}
WhisperMaster(RPCMaster*) {}
// TODO: implement the master-end of whatever the RLPClient link will send over.
};

2
walleth/MainWin.cpp

@ -61,7 +61,7 @@ Main::Main(QWidget *parent) :
g_qmlMain = this;
m_client.reset(new Client("Walleth", Address(), dev::eth::getDataDir() + "/Walleth"));
m_client.reset(new Client("Walleth", Address(), dev::getDataDir() + "/Walleth"));
g_qmlClient = m_client.get();

Loading…
Cancel
Save