diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46cc0753f..6c6ec18cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,7 +353,7 @@ if (NOT LANGUAGES)
add_subdirectory(exp)
endif ()
if(NOT ("${TARGET_PLATFORM}" STREQUAL "w64"))
- add_subdirectory(neth)
+ #add_subdirectory(neth) // resurect once moved over to WebThree API.
endif ()
if(QTQML)
add_definitions(-DETH_QTQML)
@@ -369,7 +369,7 @@ if (NOT LANGUAGES)
add_subdirectory(third)
if(QTQML)
#add_subdirectory(iethxi)
- add_subdirectory(walleth)
+ #add_subdirectory(walleth) // resurect once we want to submit ourselves to QML.
endif()
endif()
endif()
diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt
index 3eac0a0b6..c5d1aa0be 100644
--- a/alethzero/CMakeLists.txt
+++ b/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
diff --git a/alethzero/DownloadView.cpp b/alethzero/DownloadView.cpp
new file mode 100644
index 000000000..0fe5e1414
--- /dev/null
+++ b/alethzero/DownloadView.cpp
@@ -0,0 +1,40 @@
+/*
+ This file is part of cpp-ethereum.
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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
+ 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 .
+*/
+/** @file DownloadView.cpp
+ * @author Gav Wood
+ * @date 2014
+ */
+
+#include "DownloadView.h"
+
+#include
+#include
+#include
+#include "Grapher.h"
+
+using namespace std;
+using namespace dev;
+using namespace dev::eth;
+
+DownloadView::DownloadView(QWidget* _p): QWidget(_p)
+{
+}
+
+void DownloadView::paintEvent(QPaintEvent*)
+{
+ QPainter p(this);
+}
diff --git a/alethzero/DownloadView.h b/alethzero/DownloadView.h
new file mode 100644
index 000000000..ea3e05b8f
--- /dev/null
+++ b/alethzero/DownloadView.h
@@ -0,0 +1,49 @@
+/*
+ This file is part of cpp-ethereum.
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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
+ 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 .
+*/
+/** @file DownloadView.h
+ * @author Gav Wood
+ * @date 2014
+ */
+
+#pragma once
+
+#ifdef Q_MOC_RUN
+#define BOOST_MPL_IF_HPP_INCLUDED
+#endif
+
+#include
+#include
+#ifndef Q_MOC_RUN
+#include
+#endif
+
+namespace dev { namespace eth {
+struct MineInfo;
+}}
+
+class DownloadView: public QWidget
+{
+ Q_OBJECT
+
+public:
+ DownloadView(QWidget* _p = nullptr);
+
+protected:
+ virtual void paintEvent(QPaintEvent*);
+
+private:
+};
diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index aa8a43f1c..dbc4bb144 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -132,6 +132,7 @@
+
@@ -1432,6 +1433,39 @@ font-size: 14pt
+
+
+ QDockWidget::DockWidgetFeatureMask
+
+
+ Blockchain Download
+
+
+ 2
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+
+
&Quit
@@ -1698,6 +1732,14 @@ font-size: 14pt
Reserved Debug 1
+
+
+ true
+
+
+ Enable Local Addresses
+
+
@@ -1712,6 +1754,12 @@ font-size: 14pt
1
+
+ DownloadView
+ QWidget
+
+ 1
+
destination
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index e9cdf90bc..5842664b3 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -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)
{
@@ -114,7 +79,6 @@ static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr)
return QString();
}
-
Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
Main::Main(QWidget *parent) :
@@ -177,12 +141,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, {"eth", "shh"}));
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()));
@@ -226,6 +190,11 @@ Main::~Main()
writeSettings();
}
+dev::p2p::NetworkPreferences Main::netPrefs() const
+{
+ return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked());
+}
+
void Main::onKeysChanged()
{
installBalancesWatch();
@@ -233,14 +202,14 @@ void Main::onKeysChanged()
unsigned Main::installWatch(dev::eth::MessageFilter const& _tf, std::function 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 const& _f)
{
- auto ret = client()->installWatch(_tf);
+ auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
return ret;
}
@@ -255,14 +224,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 +239,9 @@ void Main::installBalancesWatch()
dev::eth::MessageFilter tf;
vector 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 +249,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 +297,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 +391,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 +421,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 +453,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 +475,7 @@ void Main::on_about_triggered()
void Main::on_paranoia_triggered()
{
- client()->setParanoia(ui->paranoia->isChecked());
+ ethereum()->setParanoia(ui->paranoia->isChecked());
}
void Main::writeSettings()
@@ -525,6 +494,7 @@ void Main::writeSettings()
s.setValue("upnp", ui->upnp->isChecked());
s.setValue("forceAddress", ui->forceAddress->text());
s.setValue("usePast", ui->usePast->isChecked());
+ s.setValue("localNetworking", ui->localNetworking->isChecked());
s.setValue("forceMining", ui->forceMining->isChecked());
s.setValue("paranoia", ui->paranoia->isChecked());
s.setValue("showAll", ui->showAll->isChecked());
@@ -537,7 +507,7 @@ void Main::writeSettings()
s.setValue("privateChain", m_privateChain);
s.setValue("verbosity", ui->verbosity->value());
- bytes d = client()->savePeers();
+ bytes d = m_webThree->savePeers();
if (d.size())
m_peers = QByteArray((char*)d.data(), (int)d.size());
s.setValue("peers", m_peers);
@@ -569,11 +539,12 @@ 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());
ui->usePast->setChecked(s.value("usePast", true).toBool());
+ ui->localNetworking->setChecked(s.value("localNetworking", true).toBool());
ui->forceMining->setChecked(s.value("forceMining", false).toBool());
on_forceMining_triggered();
ui->paranoia->setChecked(s.value("paranoia", false).toBool());
@@ -665,17 +636,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 l = client()->miningHistory();
+ list l = ethereum()->miningHistory();
static unsigned lh = 0;
if (p.hashes < lh)
ui->miningView->resetStats();
@@ -694,12 +665,12 @@ void Main::refreshBalances()
ui->ourAccounts->clear();
u256 totalBalance = 0;
map> 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 +678,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 +700,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 +722,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 +730,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 +746,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 +765,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 +778,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 +810,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 +821,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 +848,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 +919,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 +990,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 << "" << th << "
";
@@ -1049,7 +1020,7 @@ void Main::on_transactionQueue_currentItemChanged()
// s << "Pre: " << fs.rootHash() << "
";
// s << "Post: " << ts.rootHash() << "";
- s << renderDiff(client()->diff(i, 0));
+ s << renderDiff(ethereum()->diff(i, 0));
}
ui->pendingInfo->setHtml(QString::fromStdString(s.str()));
@@ -1076,7 +1047,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 +1061,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 +1086,7 @@ void Main::on_blocks_currentItemChanged()
s << "
Bloom: " << details.bloom << "";
s << "
Transactions: " << block[1].itemCount() << " @" << info.transactionsRoot << "";
s << "
Uncles: " << block[2].itemCount() << " @" << info.sha3Uncles << "";
- s << "
Pre: " << BlockInfo(client()->blockChain().block(info.parentHash)).stateRoot << "";
+ s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << "";
for (auto const& i: block[1])
s << "
" << sha3(i[0].data()).abridged() << ": " << i[1].toHash() << " [" << i[2].toInt() << " used]";
s << "
Post: " << info.stateRoot << "";
@@ -1151,7 +1122,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 +1144,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(new Executive(m_executiveState));
Transaction t = m_executiveState.pending()[txi];
m_executiveState = m_executiveState.fromPending(txi);
@@ -1199,7 +1170,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 +1236,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() << " " << showbase << hex << prettyU256(i.second).toStdString() << "
";
- s << "Body Code
" << disassemble(client()->codeAt(address));
+ s << "Body Code
" << disassemble(ethereum()->codeAt(address));
ui->contractInfo->appendHtml(QString::fromStdString(s.str()));
}
catch (dev::eth::InvalidTrie)
@@ -1281,7 +1252,7 @@ void Main::on_contracts_currentItemChanged()
void Main::on_idealPeers_valueChanged()
{
- client()->setIdealPeerCount(ui->idealPeers->value());
+ m_webThree->setIdealPeerCount(ui->idealPeers->value());
}
void Main::on_ourAccounts_doubleClicked()
@@ -1427,7 +1398,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 +1421,9 @@ 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());
+ web3()->stopNetwork();
+ ethereum()->killChain();
+ m_ethereum->setClient(ethereum());
readSettings(true);
installWatches();
refreshAll();
@@ -1495,7 +1466,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 +1485,20 @@ 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()->setIdealPeerCount(ui->idealPeers->value());
+ web3()->setNetworkPreferences(netPrefs());
+ ethereum()->setNetworkId(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 +1514,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 +1528,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 +1559,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(new Executive(m_executiveState));
Transaction t;
t.nonce = m_executiveState.transactionsFrom(dev::toAddress(s));
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index a3bfa718d..ce1a9b670 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
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 const& owned() const { return m_myKeys; }
@@ -146,6 +149,8 @@ signals:
void poll();
private:
+ dev::p2p::NetworkPreferences netPrefs() const;
+
QString pretty(dev::Address _a) const;
QString prettyU256(dev::u256 _n) const;
@@ -200,7 +205,7 @@ private:
std::unique_ptr ui;
- std::unique_ptr m_client;
+ std::unique_ptr m_webThree;
std::map> m_handlers;
unsigned m_nameRegFilter = (unsigned)-1;
diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt
index 93946aa8f..eee1d258b 100644
--- a/eth/CMakeLists.txt
+++ b/eth/CMakeLists.txt
@@ -4,13 +4,13 @@ aux_source_directory(. SRC_LIST)
include_directories(..)
link_directories(../libethcore)
-link_directories(../libethereum)
+link_directories(../libwebthree)
set(EXECUTABLE eth)
add_executable(${EXECUTABLE} ${SRC_LIST})
-target_link_libraries(${EXECUTABLE} ethereum)
+target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} gmp)
if(MINIUPNPC_LS)
diff --git a/eth/EthStubServer.cpp b/eth/EthStubServer.cpp
index 86bb1ba58..ad6a87781 100644
--- a/eth/EthStubServer.cpp
+++ b/eth/EthStubServer.cpp
@@ -25,14 +25,15 @@
#include
#include
#include
+#include
#include "CommonJS.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
-EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, Client& _client):
+EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDirect& _web3):
AbstractEthStubServer(_conn),
- m_client(_client)
+ m_web3(_web3)
{
}
@@ -59,20 +60,25 @@ Json::Value EthStubServer::procedures()
return ret;
}
+dev::eth::Client& EthStubServer::ethereum() const
+{
+ return *m_web3.ethereum();
+}
+
std::string EthStubServer::coinbase()
{
- return toJS(m_client.address());
+ return toJS(ethereum().address());
}
std::string EthStubServer::balanceAt(std::string const& _a)
{
- return toJS(m_client.balanceAt(jsToAddress(_a), 0));
+ return toJS(ethereum().balanceAt(jsToAddress(_a), 0));
}
Json::Value EthStubServer::check(Json::Value const& _as)
{
// TODO
-// if (m_client.changed())
+// if (ethereum().changed())
return _as;
/* else
{
@@ -84,7 +90,7 @@ Json::Value EthStubServer::check(Json::Value const& _as)
std::string EthStubServer::create(const std::string& _bCode, const std::string& _sec, const std::string& _xEndowment, const std::string& _xGas, const std::string& _xGasPrice)
{
- Address ret = m_client.transact(jsToSecret(_sec), jsToU256(_xEndowment), jsToBytes(_bCode), jsToU256(_xGas), jsToU256(_xGasPrice));
+ Address ret = ethereum().transact(jsToSecret(_sec), jsToU256(_xEndowment), jsToBytes(_bCode), jsToU256(_xGas), jsToU256(_xGasPrice));
return toJS(ret);
}
@@ -100,17 +106,17 @@ std::string EthStubServer::gasPrice()
bool EthStubServer::isContractAt(const std::string& _a)
{
- return m_client.codeAt(jsToAddress(_a), 0).size();
+ return ethereum().codeAt(jsToAddress(_a), 0).size();
}
bool EthStubServer::isListening()
{
- return m_client.haveNetwork();
+ return m_web3.haveNetwork();
}
bool EthStubServer::isMining()
{
- return m_client.isMining();
+ return ethereum().isMining();
}
std::string EthStubServer::key()
@@ -130,23 +136,28 @@ Json::Value EthStubServer::keys()
int EthStubServer::peerCount()
{
- return m_client.peerCount();
+ return m_web3.peerCount();
}
std::string EthStubServer::storageAt(const std::string& _a, const std::string& x)
{
- return toJS(m_client.stateAt(jsToAddress(_a), jsToU256(x), 0));
+ return toJS(ethereum().stateAt(jsToAddress(_a), jsToU256(x), 0));
+}
+
+std::string EthStubServer::stateAt(const std::string& _a, const std::string& x, const std::string& s)
+{
+ return toJS(ethereum().stateAt(jsToAddress(_a), jsToU256(x), std::atol(s.c_str())));
}
Json::Value EthStubServer::transact(const std::string& _aDest, const std::string& _bData, const std::string& _sec, const std::string& _xGas, const std::string& _xGasPrice, const std::string& _xValue)
{
- m_client.transact(jsToSecret(_sec), jsToU256(_xValue), jsToAddress(_aDest), jsToBytes(_bData), jsToU256(_xGas), jsToU256(_xGasPrice));
+ ethereum().transact(jsToSecret(_sec), jsToU256(_xValue), jsToAddress(_aDest), jsToBytes(_bData), jsToU256(_xGas), jsToU256(_xGasPrice));
return Json::Value();
}
std::string EthStubServer::txCountAt(const std::string& _a)
{
- return toJS(m_client.countAt(jsToAddress(_a), 0));
+ return toJS(ethereum().countAt(jsToAddress(_a), 0));
}
std::string EthStubServer::secretToAddress(const std::string& _a)
@@ -167,7 +178,7 @@ Json::Value EthStubServer::block(const std::string& _hash)
Json::Value EthStubServer::blockJson(const std::string& _hash)
{
Json::Value res;
- auto const& bc = m_client.blockChain();
+ auto const& bc = ethereum().blockChain();
auto b = _hash.length() ? bc.block(h256(_hash)) : bc.block();
diff --git a/eth/EthStubServer.h b/eth/EthStubServer.h
index 28af916a2..469abed07 100644
--- a/eth/EthStubServer.h
+++ b/eth/EthStubServer.h
@@ -29,12 +29,12 @@
#include "abstractethstubserver.h"
#pragma GCC diagnostic pop
-namespace dev { namespace eth { class Client; } class KeyPair; }
+namespace dev { class WebThreeDirect; namespace eth { class Client; } class KeyPair; }
class EthStubServer: public AbstractEthStubServer
{
public:
- EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::eth::Client& _client);
+ EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::WebThreeDirect& _web3);
virtual Json::Value procedures();
virtual std::string balanceAt(std::string const& _a);
@@ -49,6 +49,7 @@ public:
virtual Json::Value keys();
virtual int peerCount();
virtual std::string storageAt(const std::string& a, const std::string& x);
+ virtual std::string stateAt(const std::string& a, const std::string& x, const std::string& s);
virtual Json::Value transact(const std::string& aDest, const std::string& bData, const std::string& sec, const std::string& xGas, const std::string& xGasPrice, const std::string& xValue);
virtual std::string txCountAt(const std::string& a);
virtual std::string secretToAddress(const std::string& a);
@@ -57,7 +58,8 @@ public:
virtual Json::Value block(const std::string&);
void setKeys(std::vector _keys) { m_keys = _keys; }
private:
- dev::eth::Client& m_client;
+ dev::eth::Client& ethereum() const;
+ dev::WebThreeDirect& m_web3;
std::vector m_keys;
Json::Value jsontypeToValue(int);
Json::Value blockJson(const std::string&);
diff --git a/eth/abstractethstubserver.h b/eth/abstractethstubserver.h
index 940e4c809..7f110513d 100644
--- a/eth/abstractethstubserver.h
+++ b/eth/abstractethstubserver.h
@@ -30,6 +30,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbindAndAddMethod(new jsonrpc::Procedure("procedures", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_ARRAY, NULL), &AbstractEthStubServer::proceduresI);
this->bindAndAddMethod(new jsonrpc::Procedure("secretToAddress", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::secretToAddressI);
this->bindAndAddMethod(new jsonrpc::Procedure("storageAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"x",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::storageAtI);
+ this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"x",jsonrpc::JSON_STRING,"s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::stateAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("transact", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "aDest",jsonrpc::JSON_STRING,"bData",jsonrpc::JSON_STRING,"sec",jsonrpc::JSON_STRING,"xGas",jsonrpc::JSON_STRING,"xGasPrice",jsonrpc::JSON_STRING,"xValue",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::transactI);
this->bindAndAddMethod(new jsonrpc::Procedure("txCountAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::txCountAtI);
@@ -120,6 +121,11 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerstorageAt(request["a"].asString(), request["x"].asString());
}
+ inline virtual void stateAtI(const Json::Value& request, Json::Value& response)
+ {
+ response = this->stateAt(request["a"].asString(), request["x"].asString(), request["s"].asString());
+ }
+
inline virtual void transactI(const Json::Value& request, Json::Value& response)
{
response = this->transact(request["aDest"].asString(), request["bData"].asString(), request["sec"].asString(), request["xGas"].asString(), request["xGasPrice"].asString(), request["xValue"].asString());
@@ -148,6 +154,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServer
#include
#include
+#include
#if ETH_READLINE
#include
#include
@@ -43,6 +44,7 @@
#include "BuildInfo.h"
using namespace std;
using namespace dev;
+using namespace dev::p2p;
using namespace dev::eth;
using namespace boost::algorithm;
using dev::eth::Instruction;
@@ -110,7 +112,8 @@ void help()
<< " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl
<< " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl
<< " -n,--upnp Use upnp for NAT (default: on)." << endl
- << " -o,--mode Start a full node or a peer node (Default: full)." << endl
+ << " -L,--local-networking Use peers whose addresses are local." << endl
+ << " -o,--mode Start a full node or a peer node (Default: full)." << endl
<< " -p,--port Connect to remote port (default: 30303)." << endl
<< " -r,--remote Connect to remote host (default: none)." << endl
<< " -s,--secret Set the secret key for use with send command (default: auto)." << endl
@@ -186,6 +189,7 @@ int main(int argc, char** argv)
#endif
string publicIP;
bool upnp = true;
+ bool useLocal = false;
bool forceMining = false;
string clientName;
@@ -231,10 +235,12 @@ int main(int argc, char** argv)
upnp = false;
else
{
- cerr << "Invalid UPnP option: " << m << endl;
+ cerr << "Invalid -n/--upnp option: " << m << endl;
return -1;
}
}
+ else if (arg == "-L" || arg == "--local-networking")
+ useLocal = true;
else if ((arg == "-c" || arg == "--client-name") && i + 1 < argc)
clientName = argv[++i];
else if ((arg == "-a" || arg == "--address" || arg == "--coinbase-address") && i + 1 < argc)
@@ -254,7 +260,7 @@ int main(int argc, char** argv)
mining = i;
else
{
- cerr << "Unknown mining option: " << m << endl;
+ cerr << "Unknown -m/--mining option: " << m << endl;
return -1;
}
}
@@ -296,22 +302,28 @@ int main(int argc, char** argv)
if (!clientName.empty())
clientName += "/";
- Client c("Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), coinbase, dbPath);
-
- c.setForceMining(true);
-
cout << credits();
- c.setForceMining(forceMining);
+ NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
+ dev::WebThreeDirect web3("Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), dbPath, false, mode == NodeMode::Full ? set{"eth", "shh"} : set{}, netPrefs);
+ web3.setIdealPeerCount(peers);
+ eth::Client* c = mode == NodeMode::Full ? web3.ethereum() : nullptr;
+
+ if (c)
+ {
+ c->setForceMining(forceMining);
+ c->setAddress(coinbase);
+ }
cout << "Address: " << endl << toHex(us.address().asArray()) << endl;
- c.startNetwork(listenPort, remoteHost, remotePort, mode, peers, publicIP, upnp);
+ web3.startNetwork();
+ web3.connect(remoteHost, remotePort);
#if ETH_JSONRPC
auto_ptr jsonrpcServer;
if (jsonrpc > -1)
{
- jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c));
+ jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), web3));
jsonrpcServer->setKeys({us});
jsonrpcServer->StartListening();
}
@@ -349,34 +361,34 @@ int main(int argc, char** argv)
iss >> cmd;
if (cmd == "netstart")
{
- unsigned port;
- iss >> port;
- c.startNetwork((short)port);
+ iss >> netPrefs.listenPort;
+ web3.setNetworkPreferences(netPrefs);
+ web3.startNetwork();
}
else if (cmd == "connect")
{
string addr;
unsigned port;
iss >> addr >> port;
- c.connect(addr, (short)port);
+ web3.connect(addr, (short)port);
}
else if (cmd == "netstop")
{
- c.stopNetwork();
+ web3.stopNetwork();
}
- else if (cmd == "minestart")
+ else if (c && cmd == "minestart")
{
- c.startMining();
+ c->startMining();
}
- else if (cmd == "minestop")
+ else if (c && cmd == "minestop")
{
- c.stopMining();
+ c->stopMining();
}
- else if (cmd == "mineforce")
+ else if (c && cmd == "mineforce")
{
string enable;
iss >> enable;
- c.setForceMining(isTrue(enable));
+ c->setForceMining(isTrue(enable));
}
else if (cmd == "verbosity")
{
@@ -395,7 +407,7 @@ int main(int argc, char** argv)
{
if (jsonrpc < 0)
jsonrpc = 8080;
- jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), c));
+ jsonrpcServer = auto_ptr(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), web3));
jsonrpcServer->setKeys({us});
jsonrpcServer->StartListening();
}
@@ -416,24 +428,24 @@ int main(int argc, char** argv)
{
cout << "Secret Key: " << toHex(us.secret().asArray()) << endl;
}
- else if (cmd == "block")
+ else if (c && cmd == "block")
{
- cout << "Current block: " << c.blockChain().details().number << endl;
+ cout << "Current block: " <blockChain().details().number << endl;
}
else if (cmd == "peers")
{
- for (auto it: c.peers())
+ for (auto it: web3.peers())
cout << it.host << ":" << it.port << ", " << it.clientVersion << ", "
<< std::chrono::duration_cast(it.lastPing).count() << "ms"
<< endl;
}
- else if (cmd == "balance")
+ else if (c && cmd == "balance")
{
- cout << "Current balance: " << formatBalance(c.balanceAt(us.address())) << " = " << c.balanceAt(us.address()) << " wei" << endl;
+ cout << "Current balance: " << formatBalance( c->balanceAt(us.address())) << " = " <balanceAt(us.address()) << " wei" << endl;
}
- else if (cmd == "transact")
+ else if (c && cmd == "transact")
{
- auto const& bc = c.blockChain();
+ auto const& bc =c->blockChain();
auto h = bc.currentHash();
auto blockData = bc.block(h);
BlockInfo info(blockData);
@@ -478,35 +490,35 @@ int main(int argc, char** argv)
{
Secret secret = h256(fromHex(sechex));
Address dest = h160(fromHex(hexAddr));
- c.transact(secret, amount, dest, data, gas, gasPrice);
+ c->transact(secret, amount, dest, data, gas, gasPrice);
}
}
else
cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA";
}
- else if (cmd == "listContracts")
+ else if (c && cmd == "listContracts")
{
- auto acs = c.addresses();
+ auto acs =c->addresses();
string ss;
for (auto const& i: acs)
- if (c.codeAt(i, 0).size())
+ if ( c->codeAt(i, 0).size())
{
- ss = toString(i) + " : " + toString(c.balanceAt(i)) + " [" + toString((unsigned)c.countAt(i)) + "]";
+ ss = toString(i) + " : " + toString( c->balanceAt(i)) + " [" + toString((unsigned) c->countAt(i)) + "]";
cout << ss << endl;
}
}
- else if (cmd == "listAccounts")
+ else if (c && cmd == "listAccounts")
{
- auto acs = c.addresses();
+ auto acs =c->addresses();
string ss;
for (auto const& i: acs)
- if (c.codeAt(i, 0).empty())
+ if ( c->codeAt(i, 0).empty())
{
- ss = toString(i) + " : " + toString(c.balanceAt(i)) + " [" + toString((unsigned)c.countAt(i)) + "]";
+ ss = toString(i) + " : " + toString( c->balanceAt(i)) + " [" + toString((unsigned) c->countAt(i)) + "]";
cout << ss << endl;
}
}
- else if (cmd == "send")
+ else if (c && cmd == "send")
{
if (iss.peek() != -1)
{
@@ -522,21 +534,21 @@ int main(int argc, char** argv)
}
else
{
- auto const& bc = c.blockChain();
+ auto const& bc =c->blockChain();
auto h = bc.currentHash();
auto blockData = bc.block(h);
BlockInfo info(blockData);
u256 minGas = (u256)Client::txGas(0, 0);
Address dest = h160(fromHex(hexAddr));
- c.transact(us.secret(), amount, dest, bytes(), minGas, info.minGasPrice);
+ c->transact(us.secret(), amount, dest, bytes(), minGas, info.minGasPrice);
}
}
else
cwarn << "Require parameters: send ADDRESS AMOUNT";
}
- else if (cmd == "contract")
+ else if (c && cmd == "contract")
{
- auto const& bc = c.blockChain();
+ auto const& bc =c->blockChain();
auto h = bc.currentHash();
auto blockData = bc.block(h);
BlockInfo info(blockData);
@@ -573,12 +585,12 @@ int main(int argc, char** argv)
else if (gas < minGas)
cwarn << "Minimum gas amount is" << minGas;
else
- c.transact(us.secret(), endowment, init, gas, gasPrice);
+ c->transact(us.secret(), endowment, init, gas, gasPrice);
}
else
cwarn << "Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX";
}
- else if (cmd == "dumptrace")
+ else if (c && cmd == "dumptrace")
{
unsigned block;
unsigned index;
@@ -588,7 +600,7 @@ int main(int argc, char** argv)
ofstream f;
f.open(filename);
- dev::eth::State state = c.state(index + 1, c.blockChain().numberHash(block));
+ dev::eth::State state =c->state(index + 1,c->blockChain().numberHash(block));
if (index < state.pending().size())
{
Executive e(state);
@@ -633,7 +645,7 @@ int main(int argc, char** argv)
e.finalize(oof);
}
}
- else if (cmd == "inspect")
+ else if (c && cmd == "inspect")
{
string rechex;
iss >> rechex;
@@ -647,10 +659,10 @@ int main(int argc, char** argv)
try
{
- auto storage = c.storageAt(h, 0);
+ auto storage =c->storageAt(h, 0);
for (auto const& i: storage)
s << "@" << showbase << hex << i.first << " " << showbase << hex << i.second << endl;
- s << endl << disassemble(c.codeAt(h, 0)) << endl;
+ s << endl << disassemble( c->codeAt(h, 0)) << endl;
string outFile = getDataDir() + "/" + rechex + ".evm";
ofstream ofs;
@@ -735,19 +747,21 @@ int main(int argc, char** argv)
jsonrpcServer->StopListening();
#endif
}
- else
+ else if (c)
{
- unsigned n = c.blockChain().details().number;
+ unsigned n =c->blockChain().details().number;
if (mining)
- c.startMining();
+ c->startMining();
while (true)
{
- if (c.blockChain().details().number - n == mining)
- c.stopMining();
+ if ( c->isMining() &&c->blockChain().details().number - n == mining)
+ c->stopMining();
this_thread::sleep_for(chrono::milliseconds(100));
}
}
-
+ else
+ while (true)
+ this_thread::sleep_for(chrono::milliseconds(1000));
return 0;
}
diff --git a/exp/main.cpp b/exp/main.cpp
index c49b13e44..a88023fae 100644
--- a/exp/main.cpp
+++ b/exp/main.cpp
@@ -19,290 +19,39 @@
* @date 2014
* Ethereum client.
*/
-#if 0
-#define BOOST_RESULT_OF_USE_DECLTYPE
-#define BOOST_SPIRIT_USE_PHOENIX_V3
-#include
-#include
-#include
-#endif
#include
#include
#include
#include
#include
+#include
#include
-#if 0
-#include
-#include "BuildInfo.h"
-#endif
using namespace std;
using namespace dev;
using namespace dev::eth;
using namespace dev::p2p;
using namespace dev::shh;
-#if 0
-#if 0
-namespace qi = boost::spirit::qi;
-namespace px = boost::phoenix;
-namespace sp = boost::spirit;
-
-class ASTSymbol: public string
-{
-public:
- ASTSymbol() {}
-};
-
-enum class ASTType
-{
- Symbol,
- IntegerLiteral,
- StringLiteral,
- Call,
- Return,
- Operator,
- Compound
-};
-
-class ASTNode: public vector
-{
-public:
- ASTNode() {}
- ASTNode(ASTSymbol const& _s): m_type(ASTType::Symbol), m_s(_s) {}
- ASTNode(string const& _s): m_type(ASTType::StringLiteral), m_s(_s) {}
- ASTNode(bigint const& _i): m_type(ASTType::IntegerLiteral), m_i(_i) {}
- ASTNode(ASTType _t): m_type(_t) {}
-
- ASTNode& operator=(ASTSymbol const& _s) { m_type = ASTType::Symbol; m_s = _s; return *this; }
- ASTNode& operator=(string const& _s) { m_type = ASTType::StringLiteral; m_s = _s; return *this; }
- ASTNode& operator=(bigint const& _i) { m_type = ASTType::IntegerLiteral; m_i = _i; return *this; }
- ASTNode& operator=(ASTType const& _s) { m_type = _s; return *this; }
-
- void debugOut(ostream& _out) const;
-
-private:
- ASTType m_type;
- string m_s;
- bigint m_i;
-};
-
-void parseTree(string const& _s, ASTNode& o_out)
-{
- using qi::standard::space;
- using qi::standard::space_type;
- typedef string::const_iterator it;
-
-/* static const u256 ether = u256(1000000000) * 1000000000;
- static const u256 finney = u256(1000000000) * 1000000;
- static const u256 szabo = u256(1000000000) * 1000;*/
-
- qi::rule element;
- qi::rule call;
- qi::rule str = '"' > qi::lexeme[+(~qi::char_(std::string("\"") + '\0'))] > '"';
- qi::rule symbol = qi::lexeme[+(~qi::char_(std::string(" $@[]{}:();\"\x01-\x1f\x7f") + '\0'))];
-/* qi::rule strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;$@()[]{}:\n\t") + '\0'))];
- qi::rule intstr = qi::lexeme[ qi::no_case["0x"][qi::_val = "0x"] >> *qi::char_("0-9a-fA-F")[qi::_val += qi::_1]] | qi::lexeme[+qi::char_("0-9")[qi::_val += qi::_1]];
- qi::rule integer = intstr;
- qi::rule multiplier = qi::lit("wei")[qi::_val = 1] | qi::lit("szabo")[qi::_val = szabo] | qi::lit("finney")[qi::_val = finney] | qi::lit("ether")[qi::_val = ether];
- qi::rule quantity = integer[qi::_val = qi::_1] >> -multiplier[qi::_val *= qi::_1];
- qi::rule atom = quantity[qi::_val = px::construct(px::new_(qi::_1))] | (str | strsh)[qi::_val = qi::_1] | symbol[qi::_val = qi::_1];
- qi::rule seq = '{' > *element > '}';
- qi::rule mload = '@' > element;
- qi::rule sload = qi::lit("@@") > element;
- qi::rule mstore = '[' > element > ']' > -qi::lit(":") > element;
- qi::rule sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element;
- qi::rule calldataload = qi::lit("$") > element;
- qi::rule list = '(' > *element > ')';
-
- qi::rule extra = sload[tagNode<2>()] | mload[tagNode<1>()] | sstore[tagNode<4>()] | mstore[tagNode<3>()] | seq[tagNode<5>()] | calldataload[tagNode<6>()];*/
- qi::rule value = call[qi::_val = ASTType::Call] | str[qi::_val = qi::_1] | symbol[qi::_val = qi::_1];
- qi::rule compound = '{' > *element > '}';
- call = '(' > *value > ')'; //symbol > '(' > !(value > *(',' > value)) > ')';
- element = compound[qi::_val = ASTType::Compound] | value[qi::_val = qi::_1];
-
- auto ret = _s.cbegin();
- qi::phrase_parse(ret, _s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
- for (auto i = ret; i != _s.cend(); ++i)
- if (!isspace(*i))
- throw std::exception();
-}
-
-void ASTNode::debugOut(ostream& _out) const
-{
- switch (m_type)
- {
- case ASTType::StringLiteral:
- _out << "\"" << m_s << "\"";
- break;
- case ASTType::Symbol:
- _out << m_s;
- break;
- case ASTType::Compound:
- {
- unsigned n = 0;
- _out << "{";
- for (auto const& i: *this)
- {
- i.debugOut(_out);
- _out << ";";
- ++n;
- }
- _out << "}";
- break;
- }
- case ASTType::Call:
- {
- unsigned n = 0;
- for (auto const& i: *this)
- {
- i.debugOut(_out);
- if (n == 0)
- _out << "(";
- else if (n < size() - 1)
- _out << ",";
- if (n == size() - 1)
- _out << ")";
- ++n;
- }
- break;
- }
- default:
- _out << "nil";
- }
-}
-
-int main(int, char**)
+int main()
{
- ASTNode out;
- parseTree("{x}", out);
- out.debugOut(cout);
- cout << endl;
+ RangeMask m(0, 100);
+ cnote << m;
+ m += UnsignedRange(3, 10);
+ cnote << m;
+ m += UnsignedRange(11, 16);
+ cnote << m;
+ m += UnsignedRange(10, 11);
+ cnote << m;
+ cnote << ~m;
+ cnote << (~m).lowest(10);
+ for (auto i: (~m).lowest(10))
+ cnote << i;
return 0;
}
-#endif
-void killBigints(sp::utree const& _this)
-{
- switch (_this.which())
- {
- case sp::utree_type::list_type: for (auto const& i: _this) killBigints(i); break;
- case sp::utree_type::any_type: delete _this.get(); break;
- default:;
- }
-}
-
-void debugOutAST(ostream& _out, sp::utree const& _this)
-{
- switch (_this.which())
- {
- case sp::utree_type::list_type:
- switch (_this.tag())
- {
- case 0: { int n = 0; for (auto const& i: _this) { debugOutAST(_out, i); if (n++) _out << ", "; } break; }
- case 1: _out << "@ "; debugOutAST(_out, _this.front()); break;
- case 2: _out << "@@ "; debugOutAST(_out, _this.front()); break;
- case 3: _out << "[ "; debugOutAST(_out, _this.front()); _out << " ] "; debugOutAST(_out, _this.back()); break;
- case 4: _out << "[[ "; debugOutAST(_out, _this.front()); _out << " ]] "; debugOutAST(_out, _this.back()); break;
- case 5: _out << "{ "; for (auto const& i: _this) { debugOutAST(_out, i); _out << " "; } _out << "}"; break;
- case 6: _out << "$ "; debugOutAST(_out, _this.front()); break;
- default:
- { _out << _this.tag() << ": "; int n = 0; for (auto const& i: _this) { debugOutAST(_out, i); if (n++) _out << ", "; } break; }
- }
-
- break;
- case sp::utree_type::int_type: _out << _this.get(); break;
- case sp::utree_type::string_type: _out << "\"" << _this.get, sp::utree_type::string_type>>() << "\""; break;
- case sp::utree_type::symbol_type: _out << _this.get, sp::utree_type::symbol_type>>(); break;
- case sp::utree_type::any_type: _out << *_this.get(); break;
- default: _out << "nil";
- }
-}
-
-namespace dev {
-namespace eth {
-namespace parseTreeLLL_ {
-
-template
-struct tagNode
-{
- void operator()(sp::utree& n, qi::rule::context_type& c) const
- {
- (boost::fusion::at_c<0>(c.attributes) = n).tag(N);
- }
-};
-
-}}}
-
-void parseTree(string const& _s, sp::utree& o_out)
-{
- using qi::standard::space;
- using qi::standard::space_type;
- using dev::eth::parseTreeLLL_::tagNode;
- typedef sp::basic_string symbol_type;
- typedef string::const_iterator it;
-
- static const u256 ether = u256(1000000000) * 1000000000;
- static const u256 finney = u256(1000000000) * 1000000;
- static const u256 szabo = u256(1000000000) * 1000;
-#if 0
- qi::rule element;
- qi::rule statement;
- qi::rule str = '"' > qi::lexeme[+(~qi::char_(std::string("\"") + '\0'))] > '"';
- qi::rule strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;$@()[]{}:\n\t") + '\0'))];
- qi::rule symbol = qi::lexeme[+(~qi::char_(std::string(" $@[]{}:();\"\x01-\x1f\x7f") + '\0'))];
- qi::rule intstr = qi::lexeme[ qi::no_case["0x"][qi::_val = "0x"] >> *qi::char_("0-9a-fA-F")[qi::_val += qi::_1]] | qi::lexeme[+qi::char_("0-9")[qi::_val += qi::_1]];
- qi::rule integer = intstr;
- qi::rule multiplier = qi::lit("wei")[qi::_val = 1] | qi::lit("szabo")[qi::_val = szabo] | qi::lit("finney")[qi::_val = finney] | qi::lit("ether")[qi::_val = ether];
- qi::rule quantity = integer[qi::_val = qi::_1] >> -multiplier[qi::_val *= qi::_1];
- qi::rule atom = quantity[qi::_val = px::construct(px::new_(qi::_1))] | (str | strsh)[qi::_val = qi::_1] | symbol[qi::_val = qi::_1];
- qi::rule compound = '{' > *statement > '}';
-/* qi::rule mload = '@' > element;
- qi::rule sload = qi::lit("@@") > element;
- qi::rule mstore = '[' > element > ']' > -qi::lit(":") > element;
- qi::rule sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element;
- qi::rule calldataload = qi::lit("$") > element;*/
-// qi::rule args = '(' > (element % ',') > ')';
-
- qi::rule expression;
- qi::rule group = '(' >> expression[qi::_val = qi::_1] >> ')';
- qi::rule factor = atom | group;
- qi::rule mul = '*' >> factor;
- qi::rule div = '/' >> factor;
- qi::rule op = mul[tagNode<10>()] | div[tagNode<11>()];
- qi::rule term = factor >> !op;
- expression = term >> !(('+' >> term) | ('-' >> term));
-
- // qi::rule extra = sload[tagNode<2>()] | mload[tagNode<1>()] | sstore[tagNode<4>()] | mstore[tagNode<3>()] | calldataload[tagNode<6>()];
- statement = compound[tagNode<5>()] | (element > ';')[qi::_val = qi::_1];
- element %= expression;// | extra;
-#endif
- qi::rule symbol = qi::lexeme[+(~qi::char_(std::string(" $@[]{}:();\"\x01-\x1f\x7f") + '\0'))];
- qi::rule intstr = qi::lexeme[ qi::no_case["0x"][qi::_val = "0x"] >> *qi::char_("0-9a-fA-F")[qi::_val += qi::_1]] | qi::lexeme[+qi::char_("0-9")[qi::_val += qi::_1]];
- qi::rule integer = intstr;
- qi::rule intnode = integer[qi::_val = px::construct(px::new_(qi::_1))];
- qi::rule funcname = symbol;
- qi::rule statement;
- qi::rule call = funcname > '(' > funcname > ')';
- statement = call | intnode | symbol;
-
- auto ret = _s.cbegin();
- qi::phrase_parse(ret, _s.cend(), statement, space, qi::skip_flag::dont_postskip, o_out);
- for (auto i = ret; i != _s.cend(); ++i)
- if (!isspace(*i))
- throw std::exception();
-}
-#endif
+/*
int main(int argc, char** argv)
{
-#if 0
- sp::utree out;
- parseTree("x(2)", out);
- debugOutAST(cout, out);
- killBigints(out);
- cout << endl;
-#endif
-
g_logVerbosity = 20;
short listenPort = 30303;
@@ -322,24 +71,25 @@ int main(int argc, char** argv)
remoteHost = argv[i];
}
- Host ph("Test", listenPort, "", false, true);
+ Host ph("Test", NetworkPreferences(listenPort, "", false, true));
ph.registerCapability(new WhisperHost());
auto wh = ph.cap();
+ ph.start();
+
if (!remoteHost.empty())
ph.connect(remoteHost, remotePort);
/// Only interested in the packet if the lowest bit is 1
auto w = wh->installWatch(MessageFilter(std::vector >({{fromHex("0000000000000000000000000000000000000000000000000000000000000001"), fromHex("0000000000000000000000000000000000000000000000000000000000000001")}})));
+
for (int i = 0; ; ++i)
{
- this_thread::sleep_for(chrono::milliseconds(1000));
- ph.process();
wh->sendRaw(h256(u256(i * i)).asBytes(), h256(u256(i)).asBytes(), 1000);
for (auto i: wh->checkWatch(w))
cnote << "New message:" << (u256)h256(wh->message(i).payload);
}
-
return 0;
}
+*/
diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp
index 325ba274e..ad779e35d 100644
--- a/libdevcore/Common.cpp
+++ b/libdevcore/Common.cpp
@@ -27,7 +27,7 @@ using namespace dev;
namespace dev
{
-char const* Version = "0.6.8b";
+char const* Version = "0.6.8c";
}
diff --git a/libdevcore/RangeMask.cpp b/libdevcore/RangeMask.cpp
new file mode 100644
index 000000000..5ba4a1f73
--- /dev/null
+++ b/libdevcore/RangeMask.cpp
@@ -0,0 +1,5 @@
+#include "RangeMask.h"
+
+RangeMask::RangeMask()
+{
+}
diff --git a/libdevcore/RangeMask.h b/libdevcore/RangeMask.h
new file mode 100644
index 000000000..ba8594779
--- /dev/null
+++ b/libdevcore/RangeMask.h
@@ -0,0 +1,192 @@
+/*
+ This file is part of cpp-ethereum.
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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
+ 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 .
+*/
+/** @file EthereumHost.h
+ * @author Gav Wood
+ * @date 2014
+ */
+
+#pragma once
+
+#include