diff --git a/alethzero/MainFace.h b/alethzero/MainFace.h
index 525cc312d..d6dc3dd42 100644
--- a/alethzero/MainFace.h
+++ b/alethzero/MainFace.h
@@ -93,6 +93,7 @@ public:
virtual unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f) = 0;
virtual unsigned installWatch(dev::h256 const& _tf, WatchHandler const& _f) = 0;
+ virtual void uninstallWatch(unsigned _id) = 0;
// Account naming API
virtual void install(AccountNamer* _adopt) = 0;
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index a78949413..c2e3d5c84 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -94,8 +94,8 @@ QString dev::az::contentsOfQResource(string const& res)
}
//Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
-Address c_newConfig = Address("c6d9d2cd449a754c494264e1809c50e34d64562b");
-//Address c_nameReg = Address("ddd1cea741d548f90d86fb87a3ae6492e18c03a1");
+//Address c_newConfig = Address("c6d9d2cd449a754c494264e1809c50e34d64562b");
+Address c_nameReg = Address("96d76ae3397b52d9f61215270df65d72358709e3");
Main::Main(QWidget* _parent):
MainFace(_parent),
@@ -486,8 +486,8 @@ void Main::installWatches()
cdebug << "newBlock watch ID: " << newBlockId;
cdebug << "newPending watch ID: " << newPendingId;
- installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installNameRegWatch(); });
- installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installCurrenciesWatch(); });
+// installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installNameRegWatch(); });
+// installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installCurrenciesWatch(); });
}
Address Main::getNameReg() const
@@ -498,7 +498,8 @@ Address Main::getNameReg() const
Address Main::getCurrencies() const
{
- return abiOut
(ethereum()->call(c_newConfig, abiIn("lookup(uint256)", (u256)3)).output);
+// return abiOut(ethereum()->call(c_newConfig, abiIn("lookup(uint256)", (u256)3)).output);
+ return Address();
}
bool Main::doConfirm()
@@ -923,8 +924,8 @@ void Main::readSettings(bool _skipGeometry)
{
p->readSettings(s);
});
- static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", QString::fromStdString(toString(c_defaultGasPrice))).toString().toStdString()));
- static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", QString::fromStdString(toString(c_defaultGasPrice))).toString().toStdString()));
+ static_cast(ethereum()->gasPricer().get())->setAsk(u256(s.value("askPrice", QString::fromStdString(toString(DefaultGasPrice))).toString().toStdString()));
+ static_cast(ethereum()->gasPricer().get())->setBid(u256(s.value("bidPrice", QString::fromStdString(toString(DefaultGasPrice))).toString().toStdString()));
ui->upnp->setChecked(s.value("upnp", true).toBool());
ui->forcePublicIP->setText(s.value("forceAddress", "").toString());
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index b23a33697..e02fb5f4a 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -240,7 +240,7 @@ private:
unsigned installWatch(eth::LogFilter const& _tf, WatchHandler const& _f) override;
unsigned installWatch(h256 const& _tf, WatchHandler const& _f) override;
- void uninstallWatch(unsigned _w);
+ void uninstallWatch(unsigned _w) override;
void keysChanged();
diff --git a/alethzero/NameRegNamer.cpp b/alethzero/NameRegNamer.cpp
new file mode 100644
index 000000000..312fcbc18
--- /dev/null
+++ b/alethzero/NameRegNamer.cpp
@@ -0,0 +1,108 @@
+/*
+ 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 NameRegNamer.h
+ * @author Gav Wood
+ * @date 2015
+ */
+
+#include "NameRegNamer.h"
+#include
+#include
+#include
+using namespace std;
+using namespace dev;
+using namespace az;
+using namespace eth;
+
+DEV_AZ_NOTE_PLUGIN(NameRegNamer);
+
+NameRegNamer::NameRegNamer(MainFace* _m):
+ AccountNamerPlugin(_m, "NameRegNamer")
+{
+}
+
+NameRegNamer::~NameRegNamer()
+{
+}
+
+string NameRegNamer::toName(Address const& _a) const
+{
+ for (auto const& r: m_registrars)
+ {
+ string n = abiOut(main()->ethereum()->call(Address(1), 0, r, abiIn("name(address)", _a), 1000000, DefaultGasPrice, PendingBlock, FudgeFactor::Lenient).output);
+ if (!n.empty())
+ return n;
+ }
+ return string();
+}
+
+Address NameRegNamer::toAddress(std::string const& _n) const
+{
+ for (auto const& r: m_registrars)
+ if (Address a = abiOut(main()->ethereum()->call(r, abiIn("addr(string)", _n)).output))
+ return a;
+ return Address();
+}
+
+Addresses NameRegNamer::knownAddresses() const
+{
+ return m_knownCache;
+}
+
+void NameRegNamer::killRegistrar(Address const& _r)
+{
+ if (m_filters.count(_r))
+ {
+ main()->uninstallWatch(m_filters.at(_r));
+ m_filters.erase(_r);
+ }
+ for (auto i = m_registrars.begin(); i != m_registrars.end();)
+ if (*i == _r)
+ i = m_registrars.erase(i);
+ else
+ ++i;
+}
+
+void NameRegNamer::updateCache()
+{
+// m_forwardCache.clear();
+// m_reverseCache.clear();
+ m_knownCache.clear();
+#if ETH_FATDB || !ETH_TRUE
+ for (auto const& r: m_registrars)
+ for (u256 const& a: keysOf(ethereum()->storageAt(r)))
+ if (a < u256(1) << 160)
+ m_knownCache.push_back(Address((u160)a - 1));
+#endif
+}
+
+void NameRegNamer::readSettings(QSettings const& _s)
+{
+ (void)_s;
+ while (!m_registrars.empty())
+ killRegistrar(m_registrars.back());
+
+ Address a("047cdba9627a8686bb24b3a65d87dab7efa53d31");
+ m_registrars.push_back(a);
+ m_filters[a] = main()->installWatch(LogFilter().address(a), [=](LocalisedLogEntries const&){ updateCache(); });
+
+ noteKnownChanged();
+}
+
+void NameRegNamer::writeSettings(QSettings&)
+{
+}
diff --git a/alethzero/NameRegNamer.h b/alethzero/NameRegNamer.h
new file mode 100644
index 000000000..d56e9d41b
--- /dev/null
+++ b/alethzero/NameRegNamer.h
@@ -0,0 +1,59 @@
+/*
+ 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 NameRegNamer.h
+ * @author Gav Wood
+ * @date 2015
+ */
+
+#pragma once
+
+#include "MainFace.h"
+
+namespace dev
+{
+namespace az
+{
+
+class NameRegNamer: public QObject, public AccountNamerPlugin
+{
+ Q_OBJECT
+
+public:
+ NameRegNamer(MainFace* _m);
+ ~NameRegNamer();
+
+private:
+ void readSettings(QSettings const&) override;
+ void writeSettings(QSettings&) override;
+
+ std::string toName(Address const&) const override;
+ Address toAddress(std::string const&) const override;
+ Addresses knownAddresses() const override;
+
+ void updateCache();
+ void killRegistrar(Address const& _r);
+
+ Addresses m_registrars;
+ std::unordered_map m_filters;
+
+ mutable Addresses m_knownCache;
+// mutable std::unordered_map m_forwardCache;
+// mutable std::unordered_map m_reverseCache;
+};
+
+}
+}
diff --git a/alethzero/Transact.h b/alethzero/Transact.h
index 60d4a3c2e..015e9d3cc 100644
--- a/alethzero/Transact.h
+++ b/alethzero/Transact.h
@@ -105,6 +105,8 @@ private:
MainFace* m_main = nullptr;
NatSpecFace* m_natSpecDB = nullptr;
bool m_allGood = false;
+
+ bool m_determiningGas = false;
};
}
diff --git a/eth/main.cpp b/eth/main.cpp
index 68f1da726..7be21eb3d 100644
--- a/eth/main.cpp
+++ b/eth/main.cpp
@@ -109,8 +109,8 @@ void help()
/*<< " -B,--block-fees Set the block fee profit in the reference unit e.g. ¢ (default: 15)." << endl
<< " -e,--ether-price Set the ether price in the reference unit e.g. ¢ (default: 30.679)." << endl
<< " -P,--priority <0 - 100> Default % priority of a transaction (default: 50)." << endl*/
- << " --ask Set the minimum ask gas price under which no transactions will be mined (default " << toString(c_defaultGasPrice) << " )." << endl
- << " --bid Set the bid gas price for to pay for transactions (default " << toString(c_defaultGasPrice) << " )." << endl
+ << " --ask Set the minimum ask gas price under which no transactions will be mined (default " << toString(DefaultGasPrice) << " )." << endl
+ << " --bid Set the bid gas price for to pay for transactions (default " << toString(DefaultGasPrice) << " )." << endl
<< endl
<< "Client mining:" << endl
<< " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl
@@ -338,8 +338,8 @@ int main(int argc, char** argv)
// TransactionPriority priority = TransactionPriority::Medium;
// double etherPrice = 30.679;
// double blockFees = 15.0;
- u256 askPrice = c_defaultGasPrice;
- u256 bidPrice = c_defaultGasPrice;
+ u256 askPrice = DefaultGasPrice;
+ u256 bidPrice = DefaultGasPrice;
// javascript console
bool useConsole = false;
diff --git a/libethcore/ABI.h b/libethcore/ABI.h
index 7d7be90dd..5b7d160d0 100644
--- a/libethcore/ABI.h
+++ b/libethcore/ABI.h
@@ -43,7 +43,17 @@ template struct ABISerialiser {};
template struct ABISerialiser> { static bytes serialise(FixedHash const& _t) { static_assert(N <= 32, "Cannot serialise hash > 32 bytes."); static_assert(N > 0, "Cannot serialise zero-length hash."); return bytes(32 - N, 0) + _t.asBytes(); } };
template <> struct ABISerialiser { static bytes serialise(u256 const& _t) { return h256(_t).asBytes(); } };
template <> struct ABISerialiser { static bytes serialise(u160 const& _t) { return bytes(12, 0) + h160(_t).asBytes(); } };
-template <> struct ABISerialiser { static bytes serialise(string32 const& _t) { return bytesConstRef((byte const*)_t.data(), 32).toBytes(); } };
+template <> struct ABISerialiser { static bytes serialise(string32 const& _t) { bytes ret; bytesConstRef((byte const*)_t.data(), 32).populate(bytesRef(&ret)); return ret; } };
+template <> struct ABISerialiser
+{
+ static bytes serialise(std::string const& _t)
+ {
+ bytes ret = h256(u256(32)).asBytes() + h256(u256(_t.size())).asBytes();
+ ret.resize(ret.size() + (_t.size() + 31) / 32 * 32);
+ bytesConstRef(&_t).populate(bytesRef(&ret).cropped(64));
+ return ret;
+ }
+};
inline bytes abiInAux() { return {}; }
template bytes abiInAux(T const& _t, U const& ... _u)
@@ -61,6 +71,19 @@ template struct ABIDeserialiser> { static FixedHash
template <> struct ABIDeserialiser { static u256 deserialise(bytesConstRef& io_t) { u256 ret = fromBigEndian(io_t.cropped(0, 32)); io_t = io_t.cropped(32); return ret; } };
template <> struct ABIDeserialiser { static u160 deserialise(bytesConstRef& io_t) { u160 ret = fromBigEndian(io_t.cropped(12, 20)); io_t = io_t.cropped(32); return ret; } };
template <> struct ABIDeserialiser { static string32 deserialise(bytesConstRef& io_t) { string32 ret; io_t.cropped(0, 32).populate(bytesRef((byte*)ret.data(), 32)); io_t = io_t.cropped(32); return ret; } };
+template <> struct ABIDeserialiser
+{
+ static std::string deserialise(bytesConstRef& io_t)
+ {
+ unsigned o = (uint16_t)u256(h256(io_t.cropped(0, 32)));
+ unsigned s = (uint16_t)u256(h256(io_t.cropped(o, 32)));
+ std::string ret;
+ ret.resize(s);
+ io_t.cropped(o + 32, s).populate(bytesRef((byte*)ret.data(), s));
+ io_t = io_t.cropped(32);
+ return ret;
+ }
+};
template T abiOut(bytes const& _data)
{
diff --git a/libethereum/ClientBase.h b/libethereum/ClientBase.h
index e5e93e5d1..504fb2dbd 100644
--- a/libethereum/ClientBase.h
+++ b/libethereum/ClientBase.h
@@ -148,7 +148,7 @@ public:
using Interface::addresses;
virtual Addresses addresses(BlockNumber _block) const override;
virtual u256 gasLimitRemaining() const override;
- virtual u256 gasBidPrice() const override { return c_defaultGasPrice; }
+ virtual u256 gasBidPrice() const override { return DefaultGasPrice; }
/// Get the coinbase address
virtual Address address() const override;
diff --git a/libethereum/GasPricer.h b/libethereum/GasPricer.h
index 9a89fe94d..47867fee7 100644
--- a/libethereum/GasPricer.h
+++ b/libethereum/GasPricer.h
@@ -40,7 +40,7 @@ enum class TransactionPriority
Highest = 8
};
-static const u256 c_defaultGasPrice = 50 * shannon;
+static const u256 DefaultGasPrice = 50 * shannon;
class GasPricer
{
@@ -68,8 +68,8 @@ public:
u256 bid(TransactionPriority = TransactionPriority::Medium) const override { return m_bid; }
private:
- u256 m_ask = c_defaultGasPrice;
- u256 m_bid = c_defaultGasPrice;
+ u256 m_ask = DefaultGasPrice;
+ u256 m_bid = DefaultGasPrice;
};
}
diff --git a/libethereum/Interface.h b/libethereum/Interface.h
index 9c109000f..ed9659f3b 100644
--- a/libethereum/Interface.h
+++ b/libethereum/Interface.h
@@ -71,25 +71,25 @@ public:
virtual std::pair submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) = 0;
/// Submits the given message-call transaction.
- void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = c_defaultGasPrice, u256 const& _nonce = UndefinedU256);
+ void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 1000000, u256 const& _gasPrice = DefaultGasPrice, u256 const& _nonce = UndefinedU256);
/// Submits a new contract-creation transaction.
/// @returns the new contract's address (assuming it all goes through).
- Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 10000, u256 const& _gasPrice = c_defaultGasPrice, u256 const& _nonce = UndefinedU256);
+ Address submitTransaction(Secret const& _secret, u256 const& _endowment, bytes const& _init, u256 const& _gas = 1000000, u256 const& _gasPrice = DefaultGasPrice, u256 const& _nonce = UndefinedU256);
/// Blocks until all pending transactions have been processed.
virtual void flushTransactions() = 0;
/// Makes the given call. Nothing is recorded into the state.
virtual ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0;
- ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); }
+ ExecutionResult call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 1000000, u256 _gasPrice = DefaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(_from, _value, _dest, _data, _gas, _gasPrice, m_default, _ff); }
ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _blockNumber, _ff); }
ExecutionResult call(Secret const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return call(toAddress(_secret), _value, _dest, _data, _gas, _gasPrice, _ff); }
/// Does the given creation. Nothing is recorded into the state.
/// @returns the pair of the Address of the created contract together with its code.
virtual ExecutionResult create(Address const& _from, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) = 0;
- ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); }
+ ExecutionResult create(Address const& _from, u256 _value, bytes const& _data = bytes(), u256 _gas = 1000000, u256 _gasPrice = DefaultGasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(_from, _value, _data, _gas, _gasPrice, m_default, _ff); }
ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _blockNumber, _ff); }
ExecutionResult create(Secret const& _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, FudgeFactor _ff = FudgeFactor::Strict) { return create(toAddress(_secret), _value, _data, _gas, _gasPrice, _ff); }
diff --git a/libethereumx/Ethereum.h b/libethereumx/Ethereum.h
index 73392ea88..50eab0de3 100644
--- a/libethereumx/Ethereum.h
+++ b/libethereumx/Ethereum.h
@@ -62,11 +62,11 @@ public:
~Ethereum();
/// Submits the given message-call transaction.
- void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice);
+ void submitTransaction(Secret const& _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = DefaultGasPrice);
/// Submits a new contract-creation transaction.
/// @returns the new contract's address (assuming it all goes through).
- Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice);
+ Address submitTransaction(Secret const& _secret, u256 _endowment, bytes const& _init, u256 _gas = 10000, u256 _gasPrice = DefaultGasPrice);
/// Injects the RLP-encoded transaction given by the _rlp into the transaction queue directly.
void inject(bytesConstRef _rlp);
@@ -75,7 +75,7 @@ public:
void flushTransactions();
/// Makes the given call. Nothing is recorded into the state.
- bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = c_defaultGasPrice);
+ bytes call(Address const& _from, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = DefaultGasPrice);
// Informational stuff
diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp
index f5a6b50be..8f54b05ea 100644
--- a/test/libethereum/gaspricer.cpp
+++ b/test/libethereum/gaspricer.cpp
@@ -55,13 +55,13 @@ BOOST_AUTO_TEST_CASE(trivialGasPricer)
{
cnote << "trivialGasPricer";
std::shared_ptr gp(new TrivialGasPricer);
- BOOST_CHECK_EQUAL(gp->ask(Block()), c_defaultGasPrice);
- BOOST_CHECK_EQUAL(gp->bid(), c_defaultGasPrice);
+ BOOST_CHECK_EQUAL(gp->ask(Block()), DefaultGasPrice);
+ BOOST_CHECK_EQUAL(gp->bid(), DefaultGasPrice);
bytes bl = CanonBlockChain::createGenesisBlock();
gp->update(FullBlockChain(bl, AccountMap(), TransientDirectory().path(), WithExisting::Kill));
- BOOST_CHECK_EQUAL(gp->ask(Block()), c_defaultGasPrice);
- BOOST_CHECK_EQUAL(gp->bid(), c_defaultGasPrice);
+ BOOST_CHECK_EQUAL(gp->ask(Block()), DefaultGasPrice);
+ BOOST_CHECK_EQUAL(gp->bid(), DefaultGasPrice);
}
BOOST_AUTO_TEST_CASE(basicGasPricerNoUpdate)