Browse Source

Project-wide reorganisation of namespaces.

cl-refactor
Gav Wood 10 years ago
parent
commit
4cb7993655
  1. 4
      CMakeLists.txt
  2. 184
      alethzero/MainWin.cpp
  3. 72
      alethzero/MainWin.h
  4. 13
      alethzero/MiningView.cpp
  5. 9
      alethzero/MiningView.h
  6. 11
      eth/CommonJS.cpp
  7. 33
      eth/CommonJS.h
  8. 5
      eth/EthStubServer.cpp
  9. 11
      eth/EthStubServer.h
  10. 55
      eth/main.cpp
  11. 12
      exp/main.cpp
  12. 7
      libethcore/BlockInfo.cpp
  13. 5
      libethcore/BlockInfo.h
  14. 23
      libethcore/CommonEth.cpp
  15. 3
      libethcore/CommonEth.h
  16. 8
      libethcore/Dagger.cpp
  17. 16
      libethcore/Dagger.h
  18. 67
      libethcore/Exceptions.h
  19. 5
      libethcore/FileSystem.cpp
  20. 3
      libethcore/FileSystem.h
  21. 6
      libethcore/MemoryDB.cpp
  22. 5
      libethcore/MemoryDB.h
  23. 6
      libethcore/OverlayDB.cpp
  24. 8
      libethcore/OverlayDB.h
  25. 20
      libethcore/SHA3.cpp
  26. 3
      libethcore/SHA3.h
  27. 29
      libethcore/TrieCommon.cpp
  28. 29
      libethcore/TrieCommon.h
  29. 9
      libethcore/TrieDB.cpp
  30. 24
      libethcore/TrieDB.h
  31. 7
      libethential/Common.cpp
  32. 19
      libethential/Common.h
  33. 16
      libethential/CommonData.cpp
  34. 18
      libethential/CommonData.h
  35. 8
      libethential/CommonIO.cpp
  36. 2
      libethential/CommonIO.h
  37. 2
      libethential/Exceptions.h
  38. 4
      libethential/FixedHash.cpp
  39. 10
      libethential/FixedHash.h
  40. 4
      libethential/Guards.cpp
  41. 2
      libethential/Guards.h
  42. 12
      libethential/Log.cpp
  43. 18
      libethential/Log.h
  44. 42
      libethential/RLP.cpp
  45. 68
      libethential/RLP.h
  46. 12
      libethential/vector_ref.h
  47. 13
      libethereum/AccountDiff.cpp
  48. 9
      libethereum/AccountDiff.h
  49. 3
      libethereum/AddressState.cpp
  50. 4
      libethereum/AddressState.h
  51. 25
      libethereum/BlockChain.cpp
  52. 12
      libethereum/BlockChain.h
  53. 5
      libethereum/BlockDetails.cpp
  54. 12
      libethereum/BlockDetails.h
  55. 3
      libethereum/BlockQueue.cpp
  56. 5
      libethereum/BlockQueue.h
  57. 3
      libethereum/Client.cpp
  58. 28
      libethereum/Client.h
  59. 3
      libethereum/CommonNet.cpp
  60. 11
      libethereum/CommonNet.h
  61. 3
      libethereum/Defaults.cpp
  62. 3
      libethereum/Defaults.h
  63. 5
      libethereum/EthereumHost.cpp
  64. 7
      libethereum/EthereumHost.h
  65. 9
      libethereum/EthereumPeer.cpp
  66. 5
      libethereum/EthereumPeer.h
  67. 7
      libethereum/Executive.cpp
  68. 3
      libethereum/Executive.h
  69. 4
      libethereum/ExtVM.h
  70. 3
      libethereum/Manifest.cpp
  71. 3
      libethereum/Manifest.h
  72. 5
      libethereum/MessageFilter.cpp
  73. 3
      libethereum/MessageFilter.h
  74. 3
      libethereum/Miner.cpp
  75. 7
      libethereum/Miner.h
  76. 3
      libethereum/PastMessage.cpp
  77. 3
      libethereum/PastMessage.h
  78. 11
      libethereum/State.cpp
  79. 6
      libethereum/State.h
  80. 5
      libethereum/Transaction.cpp
  81. 9
      libethereum/Transaction.h
  82. 3
      libethereum/TransactionQueue.cpp
  83. 4
      libethereum/TransactionQueue.h
  84. 13
      libethereum/Utility.cpp
  85. 3
      libethereum/Utility.h
  86. 3
      libethereumx/Ethereum.cpp
  87. 3
      libethereumx/Ethereum.h
  88. 3
      libevm/ExtVMFace.cpp
  89. 3
      libevm/ExtVMFace.h
  90. 23
      libevm/FeeStructure.cpp
  91. 3
      libevm/FeeStructure.h
  92. 3
      libevm/VM.cpp
  93. 10
      libevm/VM.h
  94. 11
      libevmface/Instruction.cpp
  95. 3
      libevmface/Instruction.h
  96. 17
      liblll/Assembly.cpp
  97. 3
      liblll/Assembly.h
  98. 3
      liblll/CodeFragment.cpp
  99. 3
      liblll/CodeFragment.h
  100. 9
      liblll/Compiler.cpp

4
CMakeLists.txt

@ -343,9 +343,9 @@ if (NOT LANGUAGES)
add_subdirectory(libethcore) add_subdirectory(libethcore)
add_subdirectory(libevm) add_subdirectory(libevm)
add_subdirectory(libethereum) add_subdirectory(libethereum)
add_subdirectory(libethereumx) # TODO remove # add_subdirectory(libethereumx) # TODO remove
#add_subdirectory(libwebthree) add_subdirectory(libwebthree)
add_subdirectory(test) add_subdirectory(test)
add_subdirectory(eth) add_subdirectory(eth)
if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug")

184
alethzero/MainWin.cpp

@ -45,51 +45,51 @@
using namespace std; using namespace std;
// types // types
using eth::bytes; using dev::bytes;
using eth::bytesConstRef; using dev::bytesConstRef;
using eth::h160; using dev::h160;
using eth::h256; using dev::h256;
using eth::u160; using dev::u160;
using eth::u256; using dev::u256;
using eth::Address; using dev::eth::Address;
using eth::BlockInfo; using dev::eth::BlockInfo;
using eth::Client; using dev::eth::Client;
using eth::Instruction; using dev::eth::Instruction;
using eth::KeyPair; using dev::eth::KeyPair;
using eth::NodeMode; using dev::eth::NodeMode;
using eth::BlockChain; using dev::eth::BlockChain;
using p2p::PeerInfo; using dev::p2p::PeerInfo;
using eth::RLP; using dev::RLP;
using eth::Secret; using dev::eth::Secret;
using eth::Transaction; using dev::eth::Transaction;
using eth::Executive; using dev::eth::Executive;
// functions // functions
using eth::toHex; using dev::toHex;
using eth::compileLLL; using dev::fromHex;
using eth::disassemble; using dev::left160;
using eth::formatBalance; using dev::right160;
using eth::fromHex; using dev::simpleDebugOut;
using eth::sha3; using dev::toLog2;
using eth::left160; using dev::toString;
using eth::right160; using dev::operator<<;
using eth::simpleDebugOut; using dev::eth::units;
using eth::toLog2; using dev::eth::sha3;
using eth::toString; using dev::eth::compileLLL;
using eth::units; using dev::eth::disassemble;
using eth::operator<<; using dev::eth::formatBalance;
// vars // vars
using eth::g_logPost; using dev::g_logPost;
using eth::g_logVerbosity; using dev::g_logVerbosity;
static void initUnits(QComboBox* _b) static void initUnits(QComboBox* _b)
{ {
for (auto n = (::uint)units().size(); n-- != 0; ) for (auto n = (unsigned)units().size(); n-- != 0; )
_b->addItem(QString::fromStdString(units()[n].second), n); _b->addItem(QString::fromStdString(units()[n].second), n);
} }
static QString fromRaw(eth::h256 _n, unsigned* _inc = nullptr) static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr)
{ {
if (_n) if (_n)
{ {
@ -136,7 +136,7 @@ Main::Main(QWidget *parent) :
#if 0&&ETH_DEBUG #if 0&&ETH_DEBUG
m_servers.append("192.168.0.10:30301"); m_servers.append("192.168.0.10:30301");
#else #else
int pocnumber = QString(eth::EthVersion).section('.', 1, 1).toInt(); int pocnumber = QString(dev::Version).section('.', 1, 1).toInt();
if (pocnumber == 5) if (pocnumber == 5)
m_servers.push_back("54.72.69.180:30303"); m_servers.push_back("54.72.69.180:30303");
else if (pocnumber == 6) else if (pocnumber == 6)
@ -158,8 +158,8 @@ Main::Main(QWidget *parent) :
cerr << "Block Hash: " << sha3(BlockChain::createGenesisBlock()) << endl; cerr << "Block Hash: " << sha3(BlockChain::createGenesisBlock()) << endl;
cerr << "Block RLP: " << RLP(BlockChain::createGenesisBlock()) << endl; cerr << "Block RLP: " << RLP(BlockChain::createGenesisBlock()) << endl;
cerr << "Block Hex: " << toHex(BlockChain::createGenesisBlock()) << endl; cerr << "Block Hex: " << toHex(BlockChain::createGenesisBlock()) << endl;
cerr << "Network protocol version: " << eth::c_protocolVersion << endl; cerr << "Network protocol version: " << dev::eth::c_protocolVersion << endl;
cerr << "Client database version: " << eth::c_databaseVersion << endl; cerr << "Client database version: " << dev::eth::c_databaseVersion << endl;
ui->configDock->close(); ui->configDock->close();
on_verbosity_valueChanged(); on_verbosity_valueChanged();
@ -231,14 +231,14 @@ void Main::onKeysChanged()
installBalancesWatch(); installBalancesWatch();
} }
unsigned Main::installWatch(eth::MessageFilter const& _tf, std::function<void()> const& _f) unsigned Main::installWatch(dev::eth::MessageFilter const& _tf, std::function<void()> const& _f)
{ {
auto ret = m_client->installWatch(_tf); auto ret = m_client->installWatch(_tf);
m_handlers[ret] = _f; m_handlers[ret] = _f;
return ret; return ret;
} }
unsigned Main::installWatch(eth::h256 _tf, std::function<void()> const& _f) unsigned Main::installWatch(dev::h256 _tf, std::function<void()> const& _f)
{ {
auto ret = m_client->installWatch(_tf); auto ret = m_client->installWatch(_tf);
m_handlers[ret] = _f; m_handlers[ret] = _f;
@ -247,27 +247,27 @@ unsigned Main::installWatch(eth::h256 _tf, std::function<void()> const& _f)
void Main::installWatches() void Main::installWatches()
{ {
installWatch(eth::MessageFilter().altered(c_config, 0), [=](){ installNameRegWatch(); }); installWatch(dev::eth::MessageFilter().altered(c_config, 0), [=](){ installNameRegWatch(); });
installWatch(eth::MessageFilter().altered(c_config, 1), [=](){ installCurrenciesWatch(); }); installWatch(dev::eth::MessageFilter().altered(c_config, 1), [=](){ installCurrenciesWatch(); });
installWatch(eth::PendingChangedFilter, [=](){ onNewPending(); }); installWatch(dev::eth::PendingChangedFilter, [=](){ onNewPending(); });
installWatch(eth::ChainChangedFilter, [=](){ onNewBlock(); }); installWatch(dev::eth::ChainChangedFilter, [=](){ onNewBlock(); });
} }
void Main::installNameRegWatch() void Main::installNameRegWatch()
{ {
m_client->uninstallWatch(m_nameRegFilter); m_client->uninstallWatch(m_nameRegFilter);
m_nameRegFilter = installWatch(eth::MessageFilter().altered((u160)m_client->stateAt(c_config, 0)), [=](){ onNameRegChange(); }); m_nameRegFilter = installWatch(dev::eth::MessageFilter().altered((u160)m_client->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
} }
void Main::installCurrenciesWatch() void Main::installCurrenciesWatch()
{ {
m_client->uninstallWatch(m_currenciesFilter); m_client->uninstallWatch(m_currenciesFilter);
m_currenciesFilter = installWatch(eth::MessageFilter().altered((u160)m_client->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); }); m_currenciesFilter = installWatch(dev::eth::MessageFilter().altered((u160)m_client->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
} }
void Main::installBalancesWatch() void Main::installBalancesWatch()
{ {
eth::MessageFilter tf; dev::eth::MessageFilter tf;
vector<Address> altCoins; vector<Address> altCoins;
Address coinsAddr = right160(m_client->stateAt(c_config, 1)); Address coinsAddr = right160(m_client->stateAt(c_config, 1));
@ -417,7 +417,7 @@ void Main::eval(QString const& _js)
ui->jsConsole->setHtml(s); ui->jsConsole->setHtml(s);
} }
QString Main::pretty(eth::Address _a) const QString Main::pretty(dev::eth::Address _a) const
{ {
h256 n; h256 n;
@ -430,7 +430,7 @@ QString Main::pretty(eth::Address _a) const
return fromRaw(n); return fromRaw(n);
} }
QString Main::render(eth::Address _a) const QString Main::render(dev::eth::Address _a) const
{ {
QString p = pretty(_a); QString p = pretty(_a);
if (!p.isNull()) if (!p.isNull())
@ -500,7 +500,7 @@ QString Main::lookup(QString const& _a) const
void Main::on_about_triggered() void Main::on_about_triggered()
{ {
QMessageBox::about(this, "About AlethZero PoC-" + QString(eth::EthVersion).section('.', 1, 1), QString("AlethZero/v") + eth::EthVersion + "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM) "\n" ETH_QUOTED(ETH_COMMIT_HASH) + (ETH_CLEAN_REPO ? "\nCLEAN" : "\n+ LOCAL CHANGES") + "\n\nBy Gav Wood, 2014.\nBased on a design by Vitalik Buterin.\n\nThanks to the various contributors including: Alex Leverington, Tim Hughes, caktux, Eric Lombrozo, Marko Simovic."); QMessageBox::about(this, "About AlethZero PoC-" + QString(dev::Version).section('.', 1, 1), QString("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) "\n" DEV_QUOTED(ETH_COMMIT_HASH) + (ETH_CLEAN_REPO ? "\nCLEAN" : "\n+ LOCAL CHANGES") + "\n\nBy Gav Wood, 2014.\nBased on a design by Vitalik Buterin.\n\nThanks to the various contributors including: Alex Leverington, Tim Hughes, caktux, Eric Lombrozo, Marko Simovic.");
} }
void Main::on_paranoia_triggered() void Main::on_paranoia_triggered()
@ -670,18 +670,18 @@ void Main::on_preview_triggered()
void Main::refreshMining() void Main::refreshMining()
{ {
eth::MineProgress p = m_client->miningProgress(); dev::eth::MineProgress p = m_client->miningProgress();
ui->mineStatus->setText(m_client->isMining() ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Not mining"); ui->mineStatus->setText(m_client->isMining() ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Not mining");
if (!ui->miningView->isVisible()) if (!ui->miningView->isVisible())
return; return;
list<eth::MineInfo> l = m_client->miningHistory(); list<dev::eth::MineInfo> l = m_client->miningHistory();
static uint lh = 0; static unsigned lh = 0;
if (p.hashes < lh) if (p.hashes < lh)
ui->miningView->resetStats(); ui->miningView->resetStats();
lh = p.hashes; lh = p.hashes;
ui->miningView->appendStats(l, p); ui->miningView->appendStats(l, p);
/* if (p.ms) /* if (p.ms)
for (eth::MineInfo const& i: l) for (dev::eth::MineInfo const& i: l)
cnote << i.hashes * 10 << "h/sec, need:" << i.requirement << " best:" << i.best << " best-so-far:" << p.best << " avg-speed:" << (p.hashes * 1000 / p.ms) << "h/sec"; cnote << i.hashes * 10 << "h/sec, need:" << i.requirement << " best:" << i.best << " best-so-far:" << p.best << " avg-speed:" << (p.hashes * 1000 / p.ms) << "h/sec";
*/ */
} }
@ -808,10 +808,10 @@ void Main::refreshBlockCount()
cwatch << "refreshBlockCount()"; cwatch << "refreshBlockCount()";
auto d = m_client->blockChain().details(); auto d = m_client->blockChain().details();
auto diff = BlockInfo(m_client->blockChain().block()).difficulty; auto diff = BlockInfo(m_client->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(eth::c_protocolVersion).arg(eth::c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet")); 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"));
} }
static bool blockMatch(string const& _f, eth::BlockDetails const& _b, h256 _h, BlockChain const& _bc) static bool blockMatch(string const& _f, dev::eth::BlockDetails const& _b, h256 _h, BlockChain const& _bc)
{ {
try try
{ {
@ -951,7 +951,7 @@ void Main::timerEvent(QTimerEvent*)
i.second(); i.second();
} }
string Main::renderDiff(eth::StateDiff const& _d) const string Main::renderDiff(dev::eth::StateDiff const& _d) const
{ {
stringstream s; stringstream s;
@ -960,7 +960,7 @@ string Main::renderDiff(eth::StateDiff const& _d) const
{ {
s << "<hr/>"; s << "<hr/>";
eth::AccountDiff const& ad = i.second; dev::eth::AccountDiff const& ad = i.second;
s << "<code style=\"white-space: pre; font-weight: bold\">" << ad.lead() << " </code>" << " <b>" << render(i.first).toStdString() << "</b>"; s << "<code style=\"white-space: pre; font-weight: bold\">" << ad.lead() << " </code>" << " <b>" << render(i.first).toStdString() << "</b>";
if (!ad.exist.to()) if (!ad.exist.to())
continue; continue;
@ -968,12 +968,12 @@ string Main::renderDiff(eth::StateDiff const& _d) const
if (ad.balance) if (ad.balance)
{ {
s << "<br/>" << indent << "Balance " << std::dec << formatBalance(ad.balance.to()); s << "<br/>" << indent << "Balance " << std::dec << formatBalance(ad.balance.to());
s << " <b>" << std::showpos << (((eth::bigint)ad.balance.to()) - ((eth::bigint)ad.balance.from())) << std::noshowpos << "</b>"; s << " <b>" << std::showpos << (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())) << std::noshowpos << "</b>";
} }
if (ad.nonce) if (ad.nonce)
{ {
s << "<br/>" << indent << "Count #" << std::dec << ad.nonce.to(); s << "<br/>" << indent << "Count #" << std::dec << ad.nonce.to();
s << " <b>" << std::showpos << (((eth::bigint)ad.nonce.to()) - ((eth::bigint)ad.nonce.from())) << std::noshowpos << "</b>"; s << " <b>" << std::showpos << (((dev::bigint)ad.nonce.to()) - ((dev::bigint)ad.nonce.from())) << std::noshowpos << "</b>";
} }
if (ad.code) if (ad.code)
{ {
@ -982,7 +982,7 @@ string Main::renderDiff(eth::StateDiff const& _d) const
s << " (" << ad.code.from().size() << " bytes)"; s << " (" << ad.code.from().size() << " bytes)";
} }
for (pair<u256, eth::Diff<u256>> const& i: ad.storage) for (pair<u256, dev::eth::Diff<u256>> const& i: ad.storage)
{ {
s << "<br/><code style=\"white-space: pre\">"; s << "<br/><code style=\"white-space: pre\">";
if (!i.second.from()) if (!i.second.from())
@ -1041,7 +1041,7 @@ void Main::on_transactionQueue_currentItemChanged()
else else
{ {
if (tx.data.size()) if (tx.data.size())
s << eth::memDump(tx.data, 16, true); s << dev::memDump(tx.data, 16, true);
} }
s << "<hr/>"; s << "<hr/>";
@ -1148,7 +1148,7 @@ void Main::on_blocks_currentItemChanged()
else else
{ {
if (tx.data.size()) if (tx.data.size())
s << eth::memDump(tx.data, 16, true); s << dev::memDump(tx.data, 16, true);
} }
s << renderDiff(m_client->diff(txi, h)); s << renderDiff(m_client->diff(txi, h));
ui->debugCurrent->setEnabled(true); ui->debugCurrent->setEnabled(true);
@ -1209,7 +1209,7 @@ void Main::on_debugDumpStatePre_triggered()
on_debugDumpState_triggered(0); on_debugDumpState_triggered(0);
} }
void Main::populateDebugger(eth::bytesConstRef _r) void Main::populateDebugger(dev::bytesConstRef _r)
{ {
bool done = m_currentExecution->setup(_r); bool done = m_currentExecution->setup(_r);
if (!done) if (!done)
@ -1221,10 +1221,10 @@ void Main::populateDebugger(eth::bytesConstRef _r)
bytesConstRef lastData; bytesConstRef lastData;
h256 lastHash; h256 lastHash;
h256 lastDataHash; h256 lastDataHash;
auto onOp = [&](uint64_t steps, Instruction inst, eth::bigint newMemSize, eth::bigint gasCost, void* voidVM, void const* voidExt) auto onOp = [&](uint64_t steps, Instruction inst, dev::bigint newMemSize, dev::bigint gasCost, void* voidVM, void const* voidExt)
{ {
eth::VM& vm = *(eth::VM*)voidVM; dev::eth::VM& vm = *(dev::eth::VM*)voidVM;
eth::ExtVM const& ext = *(eth::ExtVM const*)voidExt; dev::eth::ExtVM const& ext = *(dev::eth::ExtVM const*)voidExt;
if (ext.code != lastExtCode) if (ext.code != lastExtCode)
{ {
lastExtCode = ext.code; lastExtCode = ext.code;
@ -1270,7 +1270,7 @@ void Main::on_contracts_currentItemChanged()
s << "<h4>Body Code</h4>" << disassemble(m_client->codeAt(address)); s << "<h4>Body Code</h4>" << disassemble(m_client->codeAt(address));
ui->contractInfo->appendHtml(QString::fromStdString(s.str())); ui->contractInfo->appendHtml(QString::fromStdString(s.str()));
} }
catch (eth::InvalidTrie) catch (dev::eth::InvalidTrie)
{ {
ui->contractInfo->appendHtml("Corrupted trie."); ui->contractInfo->appendHtml("Corrupted trie.");
} }
@ -1337,12 +1337,12 @@ void Main::on_data_textChanged()
} }
else else
{ {
m_data = eth::compileLLL(src, m_enableOptimizer, &errors); m_data = dev::eth::compileLLL(src, m_enableOptimizer, &errors);
if (errors.size()) if (errors.size())
{ {
try try
{ {
m_data = eth::asBytes(::compile(src)); m_data = dev::asBytes(::compile(src));
for (auto& i: errors) for (auto& i: errors)
i = "(LLL " + i + ")"; i = "(LLL " + i + ")";
} }
@ -1353,11 +1353,11 @@ void Main::on_data_textChanged()
} }
else else
{ {
auto asmcode = eth::compileLLLToAsm(src, false); auto asmcode = dev::eth::compileLLLToAsm(src, false);
lll = "<h4>Pre</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>"; lll = "<h4>Pre</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>";
if (m_enableOptimizer) if (m_enableOptimizer)
{ {
asmcode = eth::compileLLLToAsm(src, true); asmcode = dev::eth::compileLLLToAsm(src, true);
lll = "<h4>Opt</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>" + lll; lll = "<h4>Opt</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>" + lll;
} }
} }
@ -1399,12 +1399,12 @@ void Main::on_data_textChanged()
{ {
u256 v(d.cap(2).toStdString()); u256 v(d.cap(2).toStdString());
if (d.cap(6) == "szabo") if (d.cap(6) == "szabo")
v *= eth::szabo; v *= dev::eth::szabo;
else if (d.cap(5) == "finney") else if (d.cap(5) == "finney")
v *= eth::finney; v *= dev::eth::finney;
else if (d.cap(4) == "ether") else if (d.cap(4) == "ether")
v *= eth::ether; v *= dev::eth::ether;
bytes bs = eth::toCompactBigEndian(v); bytes bs = dev::toCompactBigEndian(v);
if (d.cap(1) != "$") if (d.cap(1) != "$")
for (auto i = bs.size(); i < 32; ++i) for (auto i = bs.size(); i < 32; ++i)
m_data.push_back(0); m_data.push_back(0);
@ -1425,7 +1425,7 @@ void Main::on_data_textChanged()
else else
s = s.mid(1); s = s.mid(1);
} }
ui->code->setHtml(QString::fromStdString(eth::memDump(m_data, 8, true))); ui->code->setHtml(QString::fromStdString(dev::memDump(m_data, 8, true)));
if (m_client->codeAt(fromString(ui->destination->currentText()), 0).size()) if (m_client->codeAt(fromString(ui->destination->currentText()), 0).size())
{ {
ui->gas->setMinimum((qint64)Client::txGas(m_data.size(), 1)); ui->gas->setMinimum((qint64)Client::txGas(m_data.size(), 1));
@ -1509,10 +1509,10 @@ void Main::on_net_triggered()
{ {
ui->port->setEnabled(!ui->net->isChecked()); ui->port->setEnabled(!ui->net->isChecked());
ui->clientName->setEnabled(!ui->net->isChecked()); ui->clientName->setEnabled(!ui->net->isChecked());
string n = string("AlethZero/v") + eth::EthVersion; string n = string("AlethZero/v") + dev::Version;
if (ui->clientName->text().size()) if (ui->clientName->text().size())
n += "/" + ui->clientName->text().toStdString(); n += "/" + ui->clientName->text().toStdString();
n += "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM); n += "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM);
m_client->setClientVersion(n); m_client->setClientVersion(n);
if (ui->net->isChecked()) if (ui->net->isChecked())
{ {
@ -1588,7 +1588,7 @@ void Main::on_debug_clicked()
m_executiveState = m_client->postState(); m_executiveState = m_client->postState();
m_currentExecution = unique_ptr<Executive>(new Executive(m_executiveState)); m_currentExecution = unique_ptr<Executive>(new Executive(m_executiveState));
Transaction t; Transaction t;
t.nonce = m_executiveState.transactionsFrom(toAddress(s)); t.nonce = m_executiveState.transactionsFrom(dev::eth::toAddress(s));
t.value = value(); t.value = value();
t.gasPrice = gasPrice(); t.gasPrice = gasPrice();
t.gas = ui->gas->value(); t.gas = ui->gas->value();
@ -1602,7 +1602,7 @@ void Main::on_debug_clicked()
} }
statusBar()->showMessage("Couldn't make transaction: no single account contains at least the required amount."); statusBar()->showMessage("Couldn't make transaction: no single account contains at least the required amount.");
} }
catch (eth::Exception const& _e) catch (dev::Exception const& _e)
{ {
statusBar()->showMessage("Error running transaction: " + QString::fromStdString(_e.description())); statusBar()->showMessage("Error running transaction: " + QString::fromStdString(_e.description()));
} }
@ -1684,7 +1684,7 @@ void Main::on_dumpTrace_triggered()
ofstream f(fn.toStdString()); ofstream f(fn.toStdString());
if (f.is_open()) if (f.is_open())
for (WorldState const& ws: m_history) for (WorldState const& ws: m_history)
f << ws.cur << " " << hex << toHex(eth::toCompactBigEndian(ws.curPC, 1)) << " " << hex << toHex(eth::toCompactBigEndian((int)(byte)ws.inst, 1)) << " " << hex << toHex(eth::toCompactBigEndian((uint64_t)ws.gas, 1)) << endl; f << ws.cur << " " << hex << toHex(dev::toCompactBigEndian(ws.curPC, 1)) << " " << hex << toHex(dev::toCompactBigEndian((int)(byte)ws.inst, 1)) << " " << hex << toHex(dev::toCompactBigEndian((uint64_t)ws.gas, 1)) << endl;
} }
void Main::on_dumpTracePretty_triggered() void Main::on_dumpTracePretty_triggered()
@ -1697,11 +1697,11 @@ void Main::on_dumpTracePretty_triggered()
f << endl << " STACK" << endl; f << endl << " STACK" << endl;
for (auto i: ws.stack) for (auto i: ws.stack)
f << (h256)i << endl; f << (h256)i << endl;
f << " MEMORY" << endl << eth::memDump(ws.memory); f << " MEMORY" << endl << dev::memDump(ws.memory);
f << " STORAGE" << endl; f << " STORAGE" << endl;
for (auto const& i: ws.storage) for (auto const& i: ws.storage)
f << showbase << hex << i.first << ": " << i.second << endl; f << showbase << hex << i.first << ": " << i.second << endl;
f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << eth::instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32"; f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32";
} }
} }
@ -1714,8 +1714,8 @@ void Main::on_dumpTraceStorage_triggered()
{ {
if (ws.inst == Instruction::STOP || ws.inst == Instruction::RETURN || ws.inst == Instruction::SUICIDE) if (ws.inst == Instruction::STOP || ws.inst == Instruction::RETURN || ws.inst == Instruction::SUICIDE)
for (auto i: ws.storage) for (auto i: ws.storage)
f << toHex(eth::toCompactBigEndian(i.first, 1)) << " " << toHex(eth::toCompactBigEndian(i.second, 1)) << endl; f << toHex(dev::toCompactBigEndian(i.first, 1)) << " " << toHex(dev::toCompactBigEndian(i.second, 1)) << endl;
f << ws.cur << " " << hex << toHex(eth::toCompactBigEndian(ws.curPC, 1)) << " " << hex << toHex(eth::toCompactBigEndian((int)(byte)ws.inst, 1)) << " " << hex << toHex(eth::toCompactBigEndian((uint64_t)ws.gas, 1)) << endl; f << ws.cur << " " << hex << toHex(dev::toCompactBigEndian(ws.curPC, 1)) << " " << hex << toHex(dev::toCompactBigEndian((int)(byte)ws.inst, 1)) << " " << hex << toHex(dev::toCompactBigEndian((uint64_t)ws.gas, 1)) << endl;
} }
} }
@ -1773,7 +1773,7 @@ void Main::on_debugTimeline_valueChanged()
updateDebugger(); updateDebugger();
} }
QString Main::prettyU256(eth::u256 _n) const QString Main::prettyU256(dev::u256 _n) const
{ {
unsigned inc = 0; unsigned inc = 0;
QString raw; QString raw;
@ -1817,7 +1817,7 @@ void Main::updateDebugger()
bytes out(size, 0); bytes out(size, 0);
for (; o < size && from + o < ws.memory.size(); ++o) for (; o < size && from + o < ws.memory.size(); ++o)
out[o] = ws.memory[from + o]; out[o] = ws.memory[from + o];
ui->debugMemory->setHtml("<h3>RETURN</h3>" + QString::fromStdString(eth::memDump(out, 16, true))); ui->debugMemory->setHtml("<h3>RETURN</h3>" + QString::fromStdString(dev::memDump(out, 16, true)));
} }
else if (ws.inst == Instruction::STOP) else if (ws.inst == Instruction::STOP)
ui->debugMemory->setHtml("<h3>STOP</h3>"); ui->debugMemory->setHtml("<h3>STOP</h3>");
@ -1827,7 +1827,7 @@ void Main::updateDebugger()
ui->debugMemory->setHtml("<h3>EXCEPTION</h3>"); ui->debugMemory->setHtml("<h3>EXCEPTION</h3>");
ostringstream ss; ostringstream ss;
ss << dec << "EXIT | GAS: " << dec << max<eth::bigint>(0, (eth::bigint)ws.gas - ws.gasCost); ss << dec << "EXIT | GAS: " << dec << max<dev::bigint>(0, (dev::bigint)ws.gas - ws.gasCost);
ui->debugStateInfo->setText(QString::fromStdString(ss.str())); ui->debugStateInfo->setText(QString::fromStdString(ss.str()));
ui->debugStorage->setHtml(""); ui->debugStorage->setHtml("");
ui->debugCallData->setHtml(""); ui->debugCallData->setHtml("");
@ -1892,7 +1892,7 @@ void Main::updateDebugger()
if (ws.callData) if (ws.callData)
{ {
assert(m_codes.count(ws.callData)); assert(m_codes.count(ws.callData));
ui->debugCallData->setHtml(QString::fromStdString(eth::memDump(m_codes[ws.callData], 16, true))); ui->debugCallData->setHtml(QString::fromStdString(dev::memDump(m_codes[ws.callData], 16, true)));
} }
else else
ui->debugCallData->setHtml(""); ui->debugCallData->setHtml("");
@ -1902,7 +1902,7 @@ void Main::updateDebugger()
for (auto i: ws.stack) for (auto i: ws.stack)
stack.prepend("<div>" + prettyU256(i) + "</div>"); stack.prepend("<div>" + prettyU256(i) + "</div>");
ui->debugStack->setHtml(stack); ui->debugStack->setHtml(stack);
ui->debugMemory->setHtml(QString::fromStdString(eth::memDump(ws.memory, 16, true))); ui->debugMemory->setHtml(QString::fromStdString(dev::memDump(ws.memory, 16, true)));
assert(m_codes.count(ws.code)); assert(m_codes.count(ws.code));
if (m_codes[ws.code].size() >= (unsigned)ws.curPC) if (m_codes[ws.code].size() >= (unsigned)ws.curPC)
@ -1916,7 +1916,7 @@ void Main::updateDebugger()
cwarn << "PC (" << (unsigned)ws.curPC << ") is after code range (" << m_codes[ws.code].size() << ")"; cwarn << "PC (" << (unsigned)ws.curPC << ") is after code range (" << m_codes[ws.code].size() << ")";
ostringstream ss; ostringstream ss;
ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << eth::instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas; ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas;
ui->debugStateInfo->setText(QString::fromStdString(ss.str())); ui->debugStateInfo->setText(QString::fromStdString(ss.str()));
stringstream s; stringstream s;
for (auto const& i: ws.storage) for (auto const& i: ws.storage)

72
alethzero/MainWin.h

@ -36,28 +36,28 @@ namespace Ui {
class Main; class Main;
} }
namespace eth { namespace dev { namespace eth {
class Client; class Client;
class State; class State;
class MessageFilter; class MessageFilter;
} }}
class QQuickView; class QQuickView;
struct WorldState struct WorldState
{ {
uint64_t steps; uint64_t steps;
eth::Address cur; dev::eth::Address cur;
eth::u256 curPC; dev::u256 curPC;
eth::Instruction inst; dev::eth::Instruction inst;
eth::bigint newMemSize; dev::bigint newMemSize;
eth::u256 gas; dev::u256 gas;
eth::h256 code; dev::h256 code;
eth::h256 callData; dev::h256 callData;
eth::u256s stack; dev::u256s stack;
eth::bytes memory; dev::bytes memory;
eth::bigint gasCost; dev::bigint gasCost;
std::map<eth::u256, eth::u256> storage; std::map<dev::u256, dev::u256> storage;
std::vector<WorldState const*> levels; std::vector<WorldState const*> levels;
}; };
@ -69,9 +69,9 @@ public:
explicit Main(QWidget *parent = 0); explicit Main(QWidget *parent = 0);
~Main(); ~Main();
eth::Client* client() { return m_client.get(); } dev::eth::Client* client() { return m_client.get(); }
QList<eth::KeyPair> const& owned() const { return m_myKeys; } QList<dev::eth::KeyPair> const& owned() const { return m_myKeys; }
public slots: public slots:
void load(QString _file); void load(QString _file);
@ -146,18 +146,18 @@ signals:
void poll(); void poll();
private: private:
QString pretty(eth::Address _a) const; QString pretty(dev::eth::Address _a) const;
QString prettyU256(eth::u256 _n) const; QString prettyU256(dev::u256 _n) const;
QString lookup(QString const& _n) const; QString lookup(QString const& _n) const;
void populateDebugger(eth::bytesConstRef r); void populateDebugger(dev::bytesConstRef r);
void initDebugger(); void initDebugger();
void updateDebugger(); void updateDebugger();
void debugFinished(); void debugFinished();
QString render(eth::Address _a) const; QString render(dev::eth::Address _a) const;
eth::Address fromString(QString const& _a) const; dev::eth::Address fromString(QString const& _a) const;
std::string renderDiff(eth::StateDiff const& _d) const; std::string renderDiff(dev::eth::StateDiff const& _d) const;
void alterDebugStateGroup(bool _enable) const; void alterDebugStateGroup(bool _enable) const;
@ -166,13 +166,13 @@ private:
void writeSettings(); void writeSettings();
bool isCreation() const; bool isCreation() const;
eth::u256 fee() const; dev::u256 fee() const;
eth::u256 total() const; dev::u256 total() const;
eth::u256 value() const; dev::u256 value() const;
eth::u256 gasPrice() const; dev::u256 gasPrice() const;
unsigned installWatch(eth::MessageFilter const& _tf, std::function<void()> const& _f); unsigned installWatch(dev::eth::MessageFilter const& _tf, std::function<void()> const& _f);
unsigned installWatch(eth::h256 _tf, std::function<void()> const& _f); unsigned installWatch(dev::h256 _tf, std::function<void()> const& _f);
void onNewPending(); void onNewPending();
void onNewBlock(); void onNewBlock();
@ -200,7 +200,7 @@ private:
std::unique_ptr<Ui::Main> ui; std::unique_ptr<Ui::Main> ui;
std::unique_ptr<eth::Client> m_client; std::unique_ptr<dev::eth::Client> m_client;
std::map<unsigned, std::function<void()>> m_handlers; std::map<unsigned, std::function<void()>> m_handlers;
unsigned m_nameRegFilter = (unsigned)-1; unsigned m_nameRegFilter = (unsigned)-1;
unsigned m_currenciesFilter = (unsigned)-1; unsigned m_currenciesFilter = (unsigned)-1;
@ -208,23 +208,23 @@ private:
QByteArray m_peers; QByteArray m_peers;
QStringList m_servers; QStringList m_servers;
QList<eth::KeyPair> m_myKeys; QList<dev::eth::KeyPair> m_myKeys;
QString m_privateChain; QString m_privateChain;
bool m_keysChanged = false; bool m_keysChanged = false;
eth::bytes m_data; dev::bytes m_data;
eth::Address m_nameReg; dev::eth::Address m_nameReg;
unsigned m_backupGas; unsigned m_backupGas;
eth::State m_executiveState; dev::eth::State m_executiveState;
std::unique_ptr<eth::Executive> m_currentExecution; std::unique_ptr<dev::eth::Executive> m_currentExecution;
eth::h256 m_lastCode; dev::h256 m_lastCode;
eth::h256 m_lastData; dev::h256 m_lastData;
std::vector<WorldState const*> m_lastLevels; std::vector<WorldState const*> m_lastLevels;
QMap<unsigned, unsigned> m_pcWarp; QMap<unsigned, unsigned> m_pcWarp;
QList<WorldState> m_history; QList<WorldState> m_history;
std::map<eth::u256, eth::bytes> m_codes; // and pcWarps std::map<dev::u256, dev::bytes> m_codes; // and pcWarps
bool m_enableOptimizer = true; bool m_enableOptimizer = true;
QNetworkAccessManager m_webCtrl; QNetworkAccessManager m_webCtrl;

13
alethzero/MiningView.cpp

@ -29,17 +29,18 @@
using namespace std; using namespace std;
using namespace lb; using namespace lb;
// do *not* use eth since eth::uint conflicts with Qt's global unit definition // do *not* use eth since unsigned conflicts with Qt's global unit definition
// using namespace eth; // using namespace dev;
using namespace dev::eth;
// types // types
using eth::MineInfo; using dev::eth::MineInfo;
using eth::MineProgress; using dev::eth::MineProgress;
// functions // functions
using eth::toString; using dev::toString;
using eth::trimFront; using dev::trimFront;
string id(float _y) { return toString(_y); } string id(float _y) { return toString(_y); }
string s(float _x){ return toString(round(_x * 1000) / 1000) + (!_x ? "s" : ""); } string s(float _x){ return toString(round(_x * 1000) / 1000) + (!_x ? "s" : ""); }

9
alethzero/MiningView.h

@ -31,10 +31,9 @@
#include <libethereum/Client.h> #include <libethereum/Client.h>
#endif #endif
namespace eth namespace dev { namespace eth {
{
struct MineInfo; struct MineInfo;
} }}
class MiningView: public QWidget class MiningView: public QWidget
{ {
@ -43,14 +42,14 @@ class MiningView: public QWidget
public: public:
MiningView(QWidget* _p = nullptr); MiningView(QWidget* _p = nullptr);
void appendStats(std::list<eth::MineInfo> const& _l, eth::MineProgress const& _p); void appendStats(std::list<dev::eth::MineInfo> const& _l, dev::eth::MineProgress const& _p);
void resetStats(); void resetStats();
protected: protected:
virtual void paintEvent(QPaintEvent*); virtual void paintEvent(QPaintEvent*);
private: private:
eth::MineProgress m_progress; dev::eth::MineProgress m_progress;
unsigned m_duration = 300; unsigned m_duration = 300;
std::vector<float> m_values; std::vector<float> m_values;
std::vector<float> m_bests; std::vector<float> m_bests;

11
eth/CommonJS.cpp

@ -22,9 +22,10 @@
#include "CommonJS.h" #include "CommonJS.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bytes eth::jsToBytes(string const& _s) bytes dev::eth::jsToBytes(string const& _s)
{ {
if (_s.substr(0, 2) == "0x") if (_s.substr(0, 2) == "0x")
// Hex // Hex
@ -37,7 +38,7 @@ bytes eth::jsToBytes(string const& _s)
return asBytes(_s); return asBytes(_s);
} }
string eth::jsPadded(string const& _s, unsigned _l, unsigned _r) string dev::eth::jsPadded(string const& _s, unsigned _l, unsigned _r)
{ {
bytes b = jsToBytes(_s); bytes b = jsToBytes(_s);
while (b.size() < _l) while (b.size() < _l)
@ -47,7 +48,7 @@ string eth::jsPadded(string const& _s, unsigned _l, unsigned _r)
return asString(b).substr(b.size() - max(_l, _r)); return asString(b).substr(b.size() - max(_l, _r));
} }
string eth::jsPadded(string const& _s, unsigned _l) string dev::eth::jsPadded(string const& _s, unsigned _l)
{ {
if (_s.substr(0, 2) == "0x" || _s.find_first_not_of("0123456789") == string::npos) if (_s.substr(0, 2) == "0x" || _s.find_first_not_of("0123456789") == string::npos)
// Numeric: pad to right // Numeric: pad to right
@ -57,7 +58,7 @@ string eth::jsPadded(string const& _s, unsigned _l)
return jsPadded(_s, 0, _l); return jsPadded(_s, 0, _l);
} }
string eth::jsUnpadded(string _s) string dev::eth::jsUnpadded(string _s)
{ {
auto p = _s.find_last_not_of((char)0); auto p = _s.find_last_not_of((char)0);
_s.resize(p == string::npos ? 0 : (p + 1)); _s.resize(p == string::npos ? 0 : (p + 1));

33
eth/CommonJS.h

@ -29,60 +29,63 @@
#include <libethential/FixedHash.h> #include <libethential/FixedHash.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
namespace dev
{
namespace eth namespace eth
{ {
eth::bytes jsToBytes(std::string const& _s); bytes jsToBytes(std::string const& _s);
std::string jsPadded(std::string const& _s, unsigned _l, unsigned _r); std::string jsPadded(std::string const& _s, unsigned _l, unsigned _r);
std::string jsPadded(std::string const& _s, unsigned _l); std::string jsPadded(std::string const& _s, unsigned _l);
std::string jsUnpadded(std::string _s); std::string jsUnpadded(std::string _s);
template <unsigned N> eth::FixedHash<N> jsToFixed(std::string const& _s) template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s)
{ {
if (_s.substr(0, 2) == "0x") if (_s.substr(0, 2) == "0x")
// Hex // Hex
return eth::FixedHash<N>(_s.substr(2)); return FixedHash<N>(_s.substr(2));
else if (_s.find_first_not_of("0123456789") == std::string::npos) else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal // Decimal
return (typename eth::FixedHash<N>::Arith)(_s); return (typename FixedHash<N>::Arith)(_s);
else else
// Binary // Binary
return eth::FixedHash<N>(asBytes(jsPadded(_s, N))); return FixedHash<N>(asBytes(jsPadded(_s, N)));
} }
template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> jsToInt(std::string const& _s) template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> jsToInt(std::string const& _s)
{ {
if (_s.substr(0, 2) == "0x") if (_s.substr(0, 2) == "0x")
// Hex // Hex
return eth::fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(eth::fromHex(_s.substr(2))); return fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(fromHex(_s.substr(2)));
else if (_s.find_first_not_of("0123456789") == std::string::npos) else if (_s.find_first_not_of("0123456789") == std::string::npos)
// Decimal // Decimal
return boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>(_s); return boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>(_s);
else else
// Binary // Binary
return eth::fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(asBytes(jsPadded(_s, N))); return fromBigEndian<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>>(asBytes(jsPadded(_s, N)));
} }
inline eth::Address jsToAddress(std::string const& _s) { return jsToFixed<20>(_s); } inline Address jsToAddress(std::string const& _s) { return jsToFixed<20>(_s); }
inline eth::Secret jsToSecret(std::string const& _s) { return jsToFixed<32>(_s); } inline Secret jsToSecret(std::string const& _s) { return jsToFixed<32>(_s); }
inline eth::u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
template <unsigned S> std::string toJS(eth::FixedHash<S> const& _h) { return "0x" + toHex(_h.ref()); } template <unsigned S> std::string toJS(FixedHash<S> const& _h) { return "0x" + toHex(_h.ref()); }
template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n) { return "0x" + eth::toHex(eth::toCompactBigEndian(_n)); } template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n) { return "0x" + toHex(toCompactBigEndian(_n)); }
inline std::string jsToBinary(std::string const& _s) inline std::string jsToBinary(std::string const& _s)
{ {
return eth::asString(jsToBytes(_s)); return asString(jsToBytes(_s));
} }
inline std::string jsToDecimal(std::string const& _s) inline std::string jsToDecimal(std::string const& _s)
{ {
return eth::toString(jsToU256(_s)); return toString(jsToU256(_s));
} }
inline std::string jsToHex(std::string const& _s) inline std::string jsToHex(std::string const& _s)
{ {
return "0x" + eth::toHex(asBytes(_s)); return "0x" + toHex(asBytes(_s));
} }
} }
}

5
eth/EthStubServer.cpp

@ -27,7 +27,8 @@
#include <libethereum/Client.h> #include <libethereum/Client.h>
#include "CommonJS.h" #include "CommonJS.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, Client& _client): EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, Client& _client):
AbstractEthStubServer(_conn), AbstractEthStubServer(_conn),
@ -89,7 +90,7 @@ std::string EthStubServer::create(const std::string& _bCode, const std::string&
std::string EthStubServer::lll(const std::string& _s) std::string EthStubServer::lll(const std::string& _s)
{ {
return "0x" + toHex(eth::compileLLL(_s)); return "0x" + toHex(dev::eth::compileLLL(_s));
} }
std::string EthStubServer::gasPrice() std::string EthStubServer::gasPrice()

11
eth/EthStubServer.h

@ -28,13 +28,12 @@
#include "abstractethstubserver.h" #include "abstractethstubserver.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
namespace eth { class Client; } namespace dev { namespace eth { class Client; class KeyPair; } }
namespace eth { class KeyPair; }
class EthStubServer: public AbstractEthStubServer class EthStubServer: public AbstractEthStubServer
{ {
public: public:
EthStubServer(jsonrpc::AbstractServerConnector* _conn, eth::Client& _client); EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::eth::Client& _client);
virtual Json::Value procedures(); virtual Json::Value procedures();
virtual std::string balanceAt(std::string const& _a); virtual std::string balanceAt(std::string const& _a);
@ -55,10 +54,10 @@ public:
virtual Json::Value lastBlock(); virtual Json::Value lastBlock();
virtual std::string lll(const std::string& s); virtual std::string lll(const std::string& s);
virtual Json::Value block(const std::string&); virtual Json::Value block(const std::string&);
void setKeys(std::vector<eth::KeyPair> _keys) { m_keys = _keys; } void setKeys(std::vector<dev::eth::KeyPair> _keys) { m_keys = _keys; }
private: private:
eth::Client& m_client; dev::eth::Client& m_client;
std::vector<eth::KeyPair> m_keys; std::vector<dev::eth::KeyPair> m_keys;
Json::Value jsontypeToValue(int); Json::Value jsontypeToValue(int);
Json::Value blockJson(const std::string&); Json::Value blockJson(const std::string&);
}; };

55
eth/main.cpp

@ -42,9 +42,10 @@
#endif #endif
#include "BuildInfo.h" #include "BuildInfo.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
using namespace boost::algorithm; using namespace boost::algorithm;
using eth::Instruction; using dev::eth::Instruction;
#undef RETURN #undef RETURN
@ -124,13 +125,13 @@ string credits(bool _interactive = false)
{ {
std::ostringstream cout; std::ostringstream cout;
cout cout
<< "Ethereum (++) " << eth::EthVersion << endl << "Ethereum (++) " << dev::Version << endl
<< " Code by Gav Wood, (c) 2013, 2014." << endl << " Code by Gav Wood, (c) 2013, 2014." << endl
<< " Based on a design by Vitalik Buterin." << endl << endl; << " Based on a design by Vitalik Buterin." << endl << endl;
if (_interactive) if (_interactive)
{ {
string vs = toString(eth::EthVersion); string vs = toString(dev::Version);
vs = vs.substr(vs.find_first_of('.') + 1)[0]; vs = vs.substr(vs.find_first_of('.') + 1)[0];
int pocnumber = stoi(vs); int pocnumber = stoi(vs);
string m_servers; string m_servers;
@ -148,13 +149,13 @@ string credits(bool _interactive = false)
void version() void version()
{ {
cout << "eth version " << eth::EthVersion << endl; cout << "eth version " << dev::Version << endl;
cout << "Build: " << ETH_QUOTED(ETH_BUILD_PLATFORM) << "/" << ETH_QUOTED(ETH_BUILD_TYPE) << endl; cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
exit(0); exit(0);
} }
Address c_config = Address("ccdeac59d35627b7de09332e819d5159e7bb7250"); Address c_config = Address("ccdeac59d35627b7de09332e819d5159e7bb7250");
string pretty(h160 _a, eth::State _st) string pretty(h160 _a, dev::eth::State _st)
{ {
string ns; string ns;
h256 n; h256 n;
@ -176,7 +177,7 @@ int main(int argc, char** argv)
string remoteHost; string remoteHost;
unsigned short remotePort = 30303; unsigned short remotePort = 30303;
string dbPath; string dbPath;
eth::uint mining = ~(eth::uint)0; unsigned mining = ~(unsigned)0;
NodeMode mode = NodeMode::Full; NodeMode mode = NodeMode::Full;
unsigned peers = 5; unsigned peers = 5;
bool interactive = false; bool interactive = false;
@ -246,7 +247,7 @@ int main(int argc, char** argv)
{ {
string m = argv[++i]; string m = argv[++i];
if (isTrue(m)) if (isTrue(m))
mining = ~(eth::uint)0; mining = ~(unsigned)0;
else if (isFalse(m)) else if (isFalse(m))
mining = 0; mining = 0;
else if (int i = stoi(m)) else if (int i = stoi(m))
@ -295,7 +296,7 @@ int main(int argc, char** argv)
if (!clientName.empty()) if (!clientName.empty())
clientName += "/"; clientName += "/";
Client c("Ethereum(++)/" + clientName + "v" + eth::EthVersion + "/" ETH_QUOTED(ETH_BUILD_TYPE) "/" ETH_QUOTED(ETH_BUILD_PLATFORM), coinbase, dbPath); Client c("Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), coinbase, dbPath);
c.setForceMining(true); c.setForceMining(true);
@ -348,14 +349,14 @@ int main(int argc, char** argv)
iss >> cmd; iss >> cmd;
if (cmd == "netstart") if (cmd == "netstart")
{ {
eth::uint port; unsigned port;
iss >> port; iss >> port;
c.startNetwork((short)port); c.startNetwork((short)port);
} }
else if (cmd == "connect") else if (cmd == "connect")
{ {
string addr; string addr;
eth::uint port; unsigned port;
iss >> addr >> port; iss >> addr >> port;
c.connect(addr, (short)port); c.connect(addr, (short)port);
} }
@ -449,7 +450,7 @@ int main(int argc, char** argv)
cnote << "Data:"; cnote << "Data:";
cnote << sdata; cnote << sdata;
bytes data = eth::parseData(sdata); bytes data = dev::eth::parseData(sdata);
cnote << "Bytes:"; cnote << "Bytes:";
string sbd = asString(data); string sbd = asString(data);
bytes bbd = asBytes(sbd); bytes bbd = asBytes(sbd);
@ -587,7 +588,7 @@ int main(int argc, char** argv)
ofstream f; ofstream f;
f.open(filename); f.open(filename);
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()) if (index < state.pending().size())
{ {
Executive e(state); Executive e(state);
@ -600,33 +601,33 @@ int main(int argc, char** argv)
if (format == "pretty") if (format == "pretty")
oof = [&](uint64_t steps, Instruction instr, bigint newMemSize, bigint gasCost, void* vvm, void const* vextVM) oof = [&](uint64_t steps, Instruction instr, bigint newMemSize, bigint gasCost, void* vvm, void const* vextVM)
{ {
eth::VM* vm = (VM*)vvm; dev::eth::VM* vm = (VM*)vvm;
eth::ExtVM const* ext = (ExtVM const*)vextVM; dev::eth::ExtVM const* ext = (ExtVM const*)vextVM;
f << endl << " STACK" << endl; f << endl << " STACK" << endl;
for (auto i: vm->stack()) for (auto i: vm->stack())
f << (h256)i << endl; f << (h256)i << endl;
f << " MEMORY" << endl << eth::memDump(vm->memory()); f << " MEMORY" << endl << dev::memDump(vm->memory());
f << " STORAGE" << endl; f << " STORAGE" << endl;
for (auto const& i: ext->state().storage(ext->myAddress)) for (auto const& i: ext->state().storage(ext->myAddress))
f << showbase << hex << i.first << ": " << i.second << endl; f << showbase << hex << i.first << ": " << i.second << endl;
f << dec << ext->level << " | " << ext->myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm->curPC() << " : " << eth::instructionInfo(instr).name << " | " << dec << vm->gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32"; f << dec << ext->level << " | " << ext->myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm->curPC() << " : " << dev::eth::instructionInfo(instr).name << " | " << dec << vm->gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32";
}; };
else if (format == "standard") else if (format == "standard")
oof = [&](uint64_t, Instruction instr, bigint, bigint, void* vvm, void const* vextVM) oof = [&](uint64_t, Instruction instr, bigint, bigint, void* vvm, void const* vextVM)
{ {
eth::VM* vm = (VM*)vvm; dev::eth::VM* vm = (VM*)vvm;
eth::ExtVM const* ext = (ExtVM const*)vextVM; dev::eth::ExtVM const* ext = (ExtVM const*)vextVM;
f << ext->myAddress << " " << hex << toHex(eth::toCompactBigEndian(vm->curPC(), 1)) << " " << hex << toHex(eth::toCompactBigEndian((int)(byte)instr, 1)) << " " << hex << toHex(eth::toCompactBigEndian((uint64_t)vm->gas(), 1)) << endl; f << ext->myAddress << " " << hex << toHex(dev::toCompactBigEndian(vm->curPC(), 1)) << " " << hex << toHex(dev::toCompactBigEndian((int)(byte)instr, 1)) << " " << hex << toHex(dev::toCompactBigEndian((uint64_t)vm->gas(), 1)) << endl;
}; };
else if (format == "standard+") else if (format == "standard+")
oof = [&](uint64_t, Instruction instr, bigint, bigint, void* vvm, void const* vextVM) oof = [&](uint64_t, Instruction instr, bigint, bigint, void* vvm, void const* vextVM)
{ {
eth::VM* vm = (VM*)vvm; dev::eth::VM* vm = (VM*)vvm;
eth::ExtVM const* ext = (ExtVM const*)vextVM; dev::eth::ExtVM const* ext = (ExtVM const*)vextVM;
if (instr == Instruction::STOP || instr == Instruction::RETURN || instr == Instruction::SUICIDE) if (instr == Instruction::STOP || instr == Instruction::RETURN || instr == Instruction::SUICIDE)
for (auto const& i: ext->state().storage(ext->myAddress)) for (auto const& i: ext->state().storage(ext->myAddress))
f << toHex(eth::toCompactBigEndian(i.first, 1)) << " " << toHex(eth::toCompactBigEndian(i.second, 1)) << endl; f << toHex(dev::toCompactBigEndian(i.first, 1)) << " " << toHex(dev::toCompactBigEndian(i.second, 1)) << endl;
f << ext->myAddress << " " << hex << toHex(eth::toCompactBigEndian(vm->curPC(), 1)) << " " << hex << toHex(eth::toCompactBigEndian((int)(byte)instr, 1)) << " " << hex << toHex(eth::toCompactBigEndian((uint64_t)vm->gas(), 1)) << endl; f << ext->myAddress << " " << hex << toHex(dev::toCompactBigEndian(vm->curPC(), 1)) << " " << hex << toHex(dev::toCompactBigEndian((int)(byte)instr, 1)) << " " << hex << toHex(dev::toCompactBigEndian((uint64_t)vm->gas(), 1)) << endl;
}; };
e.go(oof); e.go(oof);
e.finalize(oof); e.finalize(oof);
@ -659,7 +660,7 @@ int main(int argc, char** argv)
cnote << "Saved" << rechex << "to" << outFile; cnote << "Saved" << rechex << "to" << outFile;
} }
catch (eth::InvalidTrie) catch (dev::eth::InvalidTrie)
{ {
cwarn << "Corrupted trie."; cwarn << "Corrupted trie.";
} }
@ -736,7 +737,7 @@ int main(int argc, char** argv)
} }
else else
{ {
eth::uint n = c.blockChain().details().number; unsigned n = c.blockChain().details().number;
if (mining) if (mining)
c.startMining(); c.startMining();
while (true) while (true)

12
exp/main.cpp

@ -37,9 +37,10 @@
#include "BuildInfo.h" #include "BuildInfo.h"
#endif #endif
using namespace std; using namespace std;
using namespace p2p; using namespace dev;
using namespace eth; using namespace dev::eth;
using namespace shh; using namespace dev::p2p;
using namespace dev::shh;
#if 0 #if 0
#if 0 #if 0
namespace qi = boost::spirit::qi; namespace qi = boost::spirit::qi;
@ -218,6 +219,7 @@ void debugOutAST(ostream& _out, sp::utree const& _this)
} }
} }
namespace dev {
namespace eth { namespace eth {
namespace parseTreeLLL_ { namespace parseTreeLLL_ {
@ -230,13 +232,13 @@ struct tagNode
} }
}; };
}} }}}
void parseTree(string const& _s, sp::utree& o_out) void parseTree(string const& _s, sp::utree& o_out)
{ {
using qi::standard::space; using qi::standard::space;
using qi::standard::space_type; using qi::standard::space_type;
using eth::parseTreeLLL_::tagNode; using dev::eth::parseTreeLLL_::tagNode;
typedef sp::basic_string<std::string, sp::utree_type::symbol_type> symbol_type; typedef sp::basic_string<std::string, sp::utree_type::symbol_type> symbol_type;
typedef string::const_iterator it; typedef string::const_iterator it;

7
libethcore/BlockInfo.cpp

@ -28,9 +28,10 @@
#include "Exceptions.h" #include "Exceptions.h"
#include "BlockInfo.h" #include "BlockInfo.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
u256 eth::c_genesisDifficulty = (u256)1 << 17; u256 dev::eth::c_genesisDifficulty = (u256)1 << 17;
BlockInfo::BlockInfo(): timestamp(Invalid256) BlockInfo::BlockInfo(): timestamp(Invalid256)
{ {
@ -71,7 +72,7 @@ h256 BlockInfo::headerHash(bytesConstRef _block)
void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce)
{ {
hash = eth::sha3(_header.data()); hash = dev::eth::sha3(_header.data());
int field = 0; int field = 0;
try try

5
libethcore/BlockInfo.h

@ -25,6 +25,8 @@
#include <libethential/RLP.h> #include <libethential/RLP.h>
#include "CommonEth.h" #include "CommonEth.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -121,5 +123,4 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi)
} }
} }
}

23
libethcore/CommonEth.cpp

@ -25,12 +25,17 @@
#include <libethcore/SHA3.h> #include <libethcore/SHA3.h>
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
//#define ETH_ADDRESS_DEBUG 1 //#define ETH_ADDRESS_DEBUG 1
namespace dev
{
namespace eth
{
const unsigned eth::c_protocolVersion = 32; const unsigned c_protocolVersion = 32;
const unsigned eth::c_databaseVersion = 1; const unsigned c_databaseVersion = 1;
static const vector<pair<u256, string>> g_units = static const vector<pair<u256, string>> g_units =
{ {
@ -55,12 +60,12 @@ static const vector<pair<u256, string>> g_units =
{u256(1), "wei"} {u256(1), "wei"}
}; };
vector<pair<u256, string>> const& eth::units() vector<pair<u256, string>> const& units()
{ {
return g_units; return g_units;
} }
std::string eth::formatBalance(u256 _b) std::string formatBalance(u256 _b)
{ {
ostringstream ret; ostringstream ret;
if (_b > g_units[0].first * 10000) if (_b > g_units[0].first * 10000)
@ -79,7 +84,7 @@ std::string eth::formatBalance(u256 _b)
return ret.str(); return ret.str();
} }
Address eth::toAddress(Secret _private) Address toAddress(Secret _private)
{ {
secp256k1_start(); secp256k1_start();
@ -95,7 +100,7 @@ Address eth::toAddress(Secret _private)
ok = secp256k1_ecdsa_pubkey_verify(pubkey, 65); ok = secp256k1_ecdsa_pubkey_verify(pubkey, 65);
if (!ok) if (!ok)
return Address(); return Address();
auto ret = right160(eth::sha3(bytesConstRef(&(pubkey[1]), 64))); auto ret = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG #if ETH_ADDRESS_DEBUG
cout << "---- ADDRESS -------------------------------" << endl; cout << "---- ADDRESS -------------------------------" << endl;
cout << "SEC: " << _private << endl; cout << "SEC: " << _private << endl;
@ -105,6 +110,8 @@ Address eth::toAddress(Secret _private)
return ret; return ret;
} }
}}
KeyPair KeyPair::create() KeyPair KeyPair::create()
{ {
secp256k1_start(); secp256k1_start();
@ -143,7 +150,7 @@ KeyPair::KeyPair(h256 _sec):
m_secret = m_secret; m_secret = m_secret;
memcpy(m_public.data(), &(pubkey[1]), 64); memcpy(m_public.data(), &(pubkey[1]), 64);
m_address = right160(eth::sha3(bytesConstRef(&(pubkey[1]), 64))); m_address = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG #if ETH_ADDRESS_DEBUG
cout << "---- ADDRESS -------------------------------" << endl; cout << "---- ADDRESS -------------------------------" << endl;

3
libethcore/CommonEth.h

@ -26,6 +26,8 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethential/FixedHash.h> #include <libethential/FixedHash.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -117,3 +119,4 @@ private:
}; };
} }
}

8
libethcore/Dagger.cpp

@ -32,12 +32,14 @@
using namespace std; using namespace std;
using namespace std::chrono; using namespace std::chrono;
namespace dev
{
namespace eth namespace eth
{ {
#if FAKE_DAGGER #if FAKE_DAGGER
MineInfo Dagger::mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout, bool _continue, bool _turbo) MineInfo Dagger::mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, unsigned _msTimeout, bool _continue, bool _turbo)
{ {
MineInfo ret; MineInfo ret;
static std::mt19937_64 s_eng((time(0) + (unsigned)m_last)); static std::mt19937_64 s_eng((time(0) + (unsigned)m_last));
@ -91,7 +93,7 @@ bool Dagger::verify(h256 const& _root, u256 const& _nonce, u256 const& _difficul
return eval(_root, _nonce) < bound(_difficulty); return eval(_root, _nonce) < bound(_difficulty);
} }
bool Dagger::mine(u256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout, bool const& _continue) bool Dagger::mine(u256& o_solution, h256 const& _root, u256 const& _difficulty, unsigned _msTimeout, bool const& _continue)
{ {
// restart search if root has changed // restart search if root has changed
if (m_root != _root) if (m_root != _root)
@ -185,5 +187,5 @@ h256 Dagger::eval(h256 const& _root, u256 const& _nonce)
#endif #endif
} }
}
#endif #endif

16
libethcore/Dagger.h

@ -28,20 +28,17 @@
#define FAKE_DAGGER 1 #define FAKE_DAGGER 1
namespace eth namespace dev
{ {
namespace eth
inline uint toLog2(u256 _d)
{ {
return (uint)log2((double)_d);
}
struct MineInfo struct MineInfo
{ {
void combine(MineInfo const& _m) { requirement = std::max(requirement, _m.requirement); best = std::min(best, _m.best); hashes += _m.hashes; completed = completed || _m.completed; } void combine(MineInfo const& _m) { requirement = std::max(requirement, _m.requirement); best = std::min(best, _m.best); hashes += _m.hashes; completed = completed || _m.completed; }
double requirement = 0; double requirement = 0;
double best = 1e99; double best = 1e99;
uint hashes = 0; unsigned hashes = 0;
bool completed = false; bool completed = false;
}; };
@ -53,7 +50,7 @@ public:
static h256 eval(h256 const& _root, h256 const& _nonce) { h256 b[2] = { _root, _nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } static h256 eval(h256 const& _root, h256 const& _nonce) { h256 b[2] = { _root, _nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); }
static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; } static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; }
MineInfo mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout = 100, bool _continue = true, bool _turbo = false); MineInfo mine(h256& o_solution, h256 const& _root, u256 const& _difficulty, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false);
h256 m_last; h256 m_last;
}; };
@ -71,7 +68,7 @@ public:
static h256 eval(h256 const& _root, u256 const& _nonce); static h256 eval(h256 const& _root, u256 const& _nonce);
static bool verify(h256 const& _root, u256 const& _nonce, u256 const& _difficulty); static bool verify(h256 const& _root, u256 const& _nonce, u256 const& _difficulty);
bool mine(u256& o_solution, h256 const& _root, u256 const& _difficulty, uint _msTimeout = 100, bool const& _continue = bool(true)); bool mine(u256& o_solution, h256 const& _root, u256 const& _difficulty, unsigned _msTimeout = 100, bool const& _continue = bool(true));
private: private:
@ -84,5 +81,4 @@ private:
#endif #endif
} }
}

67
libethcore/Exceptions.h

@ -2,42 +2,45 @@
#include <libethential/Exceptions.h> #include <libethential/Exceptions.h>
namespace dev
{
namespace eth namespace eth
{ {
class DatabaseAlreadyOpen: public Exception {}; class DatabaseAlreadyOpen: public dev::Exception {};
class NotEnoughCash: public Exception {}; class NotEnoughCash: public dev::Exception {};
class GasPriceTooLow: public Exception {}; class GasPriceTooLow: public dev::Exception {};
class BlockGasLimitReached: public Exception {}; class BlockGasLimitReached: public dev::Exception {};
class NoSuchContract: public Exception {}; class NoSuchContract: public dev::Exception {};
class ContractAddressCollision: public Exception {}; class ContractAddressCollision: public dev::Exception {};
class FeeTooSmall: public Exception {}; class FeeTooSmall: public dev::Exception {};
class TooMuchGasUsed: public Exception {}; class TooMuchGasUsed: public dev::Exception {};
class ExtraDataTooBig: public Exception {}; class ExtraDataTooBig: public dev::Exception {};
class InvalidSignature: public Exception {}; class InvalidSignature: public dev::Exception {};
class InvalidTransactionFormat: public Exception { public: InvalidTransactionFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid transaction format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } }; class InvalidTransactionFormat: public dev::Exception { public: InvalidTransactionFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid transaction format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } };
class InvalidBlockFormat: public Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } }; class InvalidBlockFormat: public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } };
class InvalidBlockHeaderFormat: public Exception { public: InvalidBlockHeaderFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid block header format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } }; class InvalidBlockHeaderFormat: public dev::Exception { public: InvalidBlockHeaderFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual std::string description() const { return "Invalid block header format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"; } };
class InvalidUnclesHash: public Exception {}; class InvalidUnclesHash: public dev::Exception {};
class InvalidUncle: public Exception {}; class InvalidUncle: public dev::Exception {};
class UncleTooOld: public Exception {}; class UncleTooOld: public dev::Exception {};
class UncleInChain: public Exception {}; class UncleInChain: public dev::Exception {};
class DuplicateUncleNonce: public Exception {}; class DuplicateUncleNonce: public dev::Exception {};
class InvalidStateRoot: public Exception {}; class InvalidStateRoot: public dev::Exception {};
class InvalidTransactionsHash: public Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual std::string description() const { return "Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref()); } }; class InvalidTransactionsHash: public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual std::string description() const { return "Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref()); } };
class InvalidTransaction: public Exception {}; class InvalidTransaction: public dev::Exception {};
class InvalidDifficulty: public Exception {}; class InvalidDifficulty: public dev::Exception {};
class InvalidGasLimit: public Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual std::string description() const { return "Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"; } }; class InvalidGasLimit: public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual std::string description() const { return "Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"; } };
class InvalidMinGasPrice: public Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual std::string description() const { return "Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"; } }; class InvalidMinGasPrice: public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual std::string description() const { return "Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"; } };
class InvalidTransactionGasUsed: public Exception {}; class InvalidTransactionGasUsed: public dev::Exception {};
class InvalidTransactionStateRoot: public Exception {}; class InvalidTransactionStateRoot: public dev::Exception {};
class InvalidTimestamp: public Exception {}; class InvalidTimestamp: public dev::Exception {};
class InvalidNonce: public Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual std::string description() const { return "Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"; } }; class InvalidNonce: public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual std::string description() const { return "Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"; } };
class InvalidBlockNonce: public Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual std::string description() const { return "Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"; } }; class InvalidBlockNonce: public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual std::string description() const { return "Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"; } };
class InvalidParentHash: public Exception {}; class InvalidParentHash: public dev::Exception {};
class InvalidNumber: public Exception {}; class InvalidNumber: public dev::Exception {};
class InvalidContractAddress: public Exception {}; class InvalidContractAddress: public dev::Exception {};
} }
}

5
libethcore/FileSystem.cpp

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

3
libethcore/FileSystem.h

@ -25,6 +25,8 @@
#include <string> #include <string>
namespace dev
{
namespace eth namespace eth
{ {
@ -32,3 +34,4 @@ namespace eth
std::string getDataDir(); std::string getDataDir();
} }
}

6
libethcore/MemoryDB.cpp

@ -22,8 +22,11 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include "MemoryDB.h" #include "MemoryDB.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
namespace dev
{
namespace eth namespace eth
{ {
@ -113,3 +116,4 @@ set<h256> MemoryDB::keys() const
} }
} }
}

5
libethcore/MemoryDB.h

@ -27,6 +27,8 @@
#include <libethential/Log.h> #include <libethential/Log.h>
#include <libethential/RLP.h> #include <libethential/RLP.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -54,7 +56,7 @@ public:
protected: protected:
std::map<h256, std::string> m_over; std::map<h256, std::string> m_over;
std::map<h256, uint> m_refCount; std::map<h256, unsigned> m_refCount;
mutable bool m_enforceRefs = false; mutable bool m_enforceRefs = false;
}; };
@ -83,3 +85,4 @@ inline std::ostream& operator<<(std::ostream& _out, MemoryDB const& _m)
} }
} }
}

6
libethcore/OverlayDB.cpp

@ -22,8 +22,11 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include "OverlayDB.h" #include "OverlayDB.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
namespace dev
{
namespace eth namespace eth
{ {
@ -97,3 +100,4 @@ void OverlayDB::kill(h256 _h)
} }
} }
}

8
libethcore/OverlayDB.h

@ -21,12 +21,19 @@
#pragma once #pragma once
#pragma warning(push)
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
#include <memory> #include <memory>
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethential/Log.h> #include <libethential/Log.h>
#include "MemoryDB.h" #include "MemoryDB.h"
namespace ldb = leveldb; namespace ldb = leveldb;
namespace dev
{
namespace eth namespace eth
{ {
@ -56,3 +63,4 @@ private:
}; };
} }
}

20
libethcore/SHA3.cpp

@ -23,11 +23,17 @@
#include "CryptoHeaders.h" #include "CryptoHeaders.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
h256 eth::EmptySHA3 = sha3(bytesConstRef()); namespace dev
{
namespace eth
{
h256 EmptySHA3 = sha3(bytesConstRef());
std::string eth::sha3(std::string const& _input, bool _hex) std::string sha3(std::string const& _input, bool _hex)
{ {
if (!_hex) if (!_hex)
{ {
@ -44,7 +50,7 @@ std::string eth::sha3(std::string const& _input, bool _hex)
return ret; return ret;
} }
void eth::sha3(bytesConstRef _input, bytesRef _output) void sha3(bytesConstRef _input, bytesRef _output)
{ {
CryptoPP::SHA3_256 ctx; CryptoPP::SHA3_256 ctx;
ctx.Update((byte*)_input.data(), _input.size()); ctx.Update((byte*)_input.data(), _input.size());
@ -52,17 +58,19 @@ void eth::sha3(bytesConstRef _input, bytesRef _output)
ctx.Final(_output.data()); ctx.Final(_output.data());
} }
bytes eth::sha3Bytes(bytesConstRef _input) bytes sha3Bytes(bytesConstRef _input)
{ {
bytes ret(32); bytes ret(32);
sha3(_input, &ret); sha3(_input, &ret);
return ret; return ret;
} }
h256 eth::sha3(bytesConstRef _input) h256 sha3(bytesConstRef _input)
{ {
h256 ret; h256 ret;
sha3(_input, bytesRef(&ret[0], 32)); sha3(_input, bytesRef(&ret[0], 32));
return ret; return ret;
} }
}
}

3
libethcore/SHA3.h

@ -27,6 +27,8 @@
#include <libethential/FixedHash.h> #include <libethential/FixedHash.h>
#include <libethential/vector_ref.h> #include <libethential/vector_ref.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -59,3 +61,4 @@ inline h256 sha3(std::string const& _input) { return sha3(bytesConstRef(_input))
extern h256 EmptySHA3; extern h256 EmptySHA3;
} }
}

29
libethcore/TrieCommon.cpp

@ -21,6 +21,8 @@
#include "TrieCommon.h" #include "TrieCommon.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -42,8 +44,8 @@ namespace eth
std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf, int _begin, int _end) std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf, int _begin, int _end)
{ {
uint begin = _begin; unsigned begin = _begin;
uint end = _end < 0 ? _hexVector.size() + 1 + _end : _end; unsigned end = _end < 0 ? _hexVector.size() + 1 + _end : _end;
bool odd = ((end - begin) % 2) != 0; bool odd = ((end - begin) % 2) != 0;
std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16); std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16);
@ -52,21 +54,21 @@ std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf, int _begin, int
ret[0] |= _hexVector[begin]; ret[0] |= _hexVector[begin];
++begin; ++begin;
} }
for (uint i = begin; i < end; i += 2) for (unsigned i = begin; i < end; i += 2)
ret += _hexVector[i] * 16 + _hexVector[i + 1]; ret += _hexVector[i] * 16 + _hexVector[i + 1];
return ret; return ret;
} }
std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, uint _offset) std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, unsigned _offset)
{ {
uint begin = _beginNibble + _offset; unsigned begin = _beginNibble + _offset;
uint end = (_endNibble < 0 ? (_data.size() * 2 - _offset) + 1 + _endNibble : _endNibble) + _offset; unsigned end = (_endNibble < 0 ? (_data.size() * 2 - _offset) + 1 + _endNibble : _endNibble) + _offset;
bool odd = (end - begin) & 1; bool odd = (end - begin) & 1;
std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16); std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16);
ret.reserve((end - begin) / 2 + 1); ret.reserve((end - begin) / 2 + 1);
uint d = odd ? 1 : 2; unsigned d = odd ? 1 : 2;
for (auto i = begin; i < end; ++i, ++d) for (auto i = begin; i < end; ++i, ++d)
{ {
byte n = nibble(_data, i); byte n = nibble(_data, i);
@ -78,19 +80,19 @@ std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, i
return ret; return ret;
} }
std::string hexPrefixEncode(bytesConstRef _d1, uint _o1, bytesConstRef _d2, uint _o2, bool _leaf) std::string hexPrefixEncode(bytesConstRef _d1, unsigned _o1, bytesConstRef _d2, unsigned _o2, bool _leaf)
{ {
uint begin1 = _o1; unsigned begin1 = _o1;
uint end1 = _d1.size() * 2; unsigned end1 = _d1.size() * 2;
uint begin2 = _o2; unsigned begin2 = _o2;
uint end2 = _d2.size() * 2; unsigned end2 = _d2.size() * 2;
bool odd = (end1 - begin1 + end2 - begin2) & 1; bool odd = (end1 - begin1 + end2 - begin2) & 1;
std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16); std::string ret(1, ((_leaf ? 2 : 0) | (odd ? 1 : 0)) * 16);
ret.reserve((end1 - begin1 + end2 - begin2) / 2 + 1); ret.reserve((end1 - begin1 + end2 - begin2) / 2 + 1);
uint d = odd ? 1 : 2; unsigned d = odd ? 1 : 2;
for (auto i = begin1; i < end1; ++i, ++d) for (auto i = begin1; i < end1; ++i, ++d)
{ {
byte n = nibble(_d1, i); byte n = nibble(_d1, i);
@ -125,3 +127,4 @@ byte uniqueInUse(RLP const& _orig, byte except)
} }
} }
}

29
libethcore/TrieCommon.h

@ -24,40 +24,42 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethential/RLP.h> #include <libethential/RLP.h>
namespace dev
{
namespace eth namespace eth
{ {
inline byte nibble(bytesConstRef _data, uint _i) inline byte nibble(bytesConstRef _data, unsigned _i)
{ {
return (_i & 1) ? (_data[_i / 2] & 15) : (_data[_i / 2] >> 4); return (_i & 1) ? (_data[_i / 2] & 15) : (_data[_i / 2] >> 4);
} }
inline uint sharedNibbles(bytesConstRef _a, uint _ab, uint _ae, bytesConstRef _b, uint _bb, uint _be) inline unsigned sharedNibbles(bytesConstRef _a, unsigned _ab, unsigned _ae, bytesConstRef _b, unsigned _bb, unsigned _be)
{ {
uint ret = 0; unsigned ret = 0;
for (uint ai = _ab, bi = _bb; ai < _ae && bi < _be && nibble(_a, ai) == nibble(_b, bi); ++ai, ++bi, ++ret) {} for (unsigned ai = _ab, bi = _bb; ai < _ae && bi < _be && nibble(_a, ai) == nibble(_b, bi); ++ai, ++bi, ++ret) {}
return ret; return ret;
} }
struct NibbleSlice struct NibbleSlice
{ {
bytesConstRef data; bytesConstRef data;
uint offset; unsigned offset;
NibbleSlice(bytesConstRef _d = bytesConstRef(), uint _o = 0): data(_d), offset(_o) {} NibbleSlice(bytesConstRef _d = bytesConstRef(), unsigned _o = 0): data(_d), offset(_o) {}
byte operator[](uint _index) const { return nibble(data, offset + _index); } byte operator[](unsigned _index) const { return nibble(data, offset + _index); }
uint size() const { return data.size() * 2 - offset; } unsigned size() const { return data.size() * 2 - offset; }
NibbleSlice mid(uint _index) const { return NibbleSlice(data, offset + _index); } NibbleSlice mid(unsigned _index) const { return NibbleSlice(data, offset + _index); }
bool contains(NibbleSlice _k) const { return shared(_k) == _k.size(); } bool contains(NibbleSlice _k) const { return shared(_k) == _k.size(); }
uint shared(NibbleSlice _k) const { return sharedNibbles(data, offset, offset + size(), _k.data, _k.offset, _k.offset + _k.size()); } unsigned shared(NibbleSlice _k) const { return sharedNibbles(data, offset, offset + size(), _k.data, _k.offset, _k.offset + _k.size()); }
bool operator==(NibbleSlice _k) const { return _k.size() == size() && shared(_k) == _k.size(); } bool operator==(NibbleSlice _k) const { return _k.size() == size() && shared(_k) == _k.size(); }
bool operator!=(NibbleSlice _s) const { return !operator==(_s); } bool operator!=(NibbleSlice _s) const { return !operator==(_s); }
}; };
inline std::ostream& operator<<(std::ostream& _out, NibbleSlice const& _m) inline std::ostream& operator<<(std::ostream& _out, NibbleSlice const& _m)
{ {
for (uint i = 0; i < _m.size(); ++i) for (unsigned i = 0; i < _m.size(); ++i)
_out << std::hex << (int)_m[i] << std::dec; _out << std::hex << (int)_m[i] << std::dec;
return _out; return _out;
} }
@ -86,8 +88,8 @@ inline NibbleSlice keyOf(RLP const& _twoItem)
byte uniqueInUse(RLP const& _orig, byte except); byte uniqueInUse(RLP const& _orig, byte except);
std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf = false, int _begin = 0, int _end = -1); std::string hexPrefixEncode(bytes const& _hexVector, bool _leaf = false, int _begin = 0, int _end = -1);
std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, uint _offset); std::string hexPrefixEncode(bytesConstRef _data, bool _leaf, int _beginNibble, int _endNibble, unsigned _offset);
std::string hexPrefixEncode(bytesConstRef _d1, uint _o1, bytesConstRef _d2, uint _o2, bool _leaf); std::string hexPrefixEncode(bytesConstRef _d1, unsigned _o1, bytesConstRef _d2, unsigned _o2, bool _leaf);
inline std::string hexPrefixEncode(NibbleSlice _s, bool _leaf, int _begin = 0, int _end = -1) inline std::string hexPrefixEncode(NibbleSlice _s, bool _leaf, int _begin = 0, int _end = -1)
{ {
@ -100,3 +102,4 @@ inline std::string hexPrefixEncode(NibbleSlice _s1, NibbleSlice _s2, bool _leaf)
} }
} }
}

9
libethcore/TrieDB.cpp

@ -22,14 +22,11 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include "TrieDB.h" #include "TrieDB.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
namespace eth
{
#if !ETH_LANGUAGES #if !ETH_LANGUAGES
const h256 c_shaNull = sha3(rlp("")); const h256 dev::eth::c_shaNull = sha3(rlp(""));
#endif #endif
}

24
libethcore/TrieDB.h

@ -21,6 +21,11 @@
#pragma once #pragma once
#pragma warning(push)
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
#include <map> #include <map>
#include <memory> #include <memory>
#include <libethential/Common.h> #include <libethential/Common.h>
@ -31,6 +36,8 @@
#include "TrieCommon.h" #include "TrieCommon.h"
namespace ldb = leveldb; namespace ldb = leveldb;
namespace dev
{
namespace eth namespace eth
{ {
@ -223,7 +230,7 @@ private:
// in: [K1 & K2, V] (DEL) : nibbles(K1) == _s, 0 < _s <= nibbles(K1 & K2) // in: [K1 & K2, V] (DEL) : nibbles(K1) == _s, 0 < _s <= nibbles(K1 & K2)
// out: [K1, H] ; [K2, V] => H (INS) (being [K1, [K2, V]] if necessary) // out: [K1, H] ; [K2, V] => H (INS) (being [K1, [K2, V]] if necessary)
bytes cleve(RLP const& _orig, uint _s); bytes cleve(RLP const& _orig, unsigned _s);
// in: [K1, H] (DEL) ; H <= [K2, V] (DEL) (being [K1, [K2, V]] (DEL) if necessary) // in: [K1, H] (DEL) ; H <= [K2, V] (DEL) (being [K1, [K2, V]] (DEL) if necessary)
// out: [K1 & K2, V] // out: [K1 & K2, V]
@ -308,9 +315,12 @@ std::ostream& operator<<(std::ostream& _out, TrieDB<KeyType, DB> const& _db)
return _out; return _out;
} }
}
} }
// Template implementations... // Template implementations...
namespace dev
{
namespace eth namespace eth
{ {
@ -756,7 +766,7 @@ template <class DB> bytes GenericTrieDB<DB>::place(RLP const& _orig, NibbleSlice
return (RLPStream(2) << _orig[0] << _s).out(); return (RLPStream(2) << _orig[0] << _s).out();
auto s = RLPStream(17); auto s = RLPStream(17);
for (uint i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
s << _orig[i]; s << _orig[i];
s << _s; s << _s;
return s.out(); return s.out();
@ -778,7 +788,7 @@ template <class DB> bytes GenericTrieDB<DB>::remove(RLP const& _orig)
if (_orig.itemCount() == 2) if (_orig.itemCount() == 2)
return RLPNull; return RLPNull;
RLPStream r(17); RLPStream r(17);
for (uint i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
r << _orig[i]; r << _orig[i];
r << ""; r << "";
return r.out(); return r.out();
@ -793,7 +803,7 @@ template <class DB> RLPStream& GenericTrieDB<DB>::streamNode(RLPStream& _s, byte
return _s; return _s;
} }
template <class DB> bytes GenericTrieDB<DB>::cleve(RLP const& _orig, uint _s) template <class DB> bytes GenericTrieDB<DB>::cleve(RLP const& _orig, unsigned _s)
{ {
#if ETH_PARANOIA #if ETH_PARANOIA
tdebug << "cleve " << _orig << _s; tdebug << "cleve " << _orig << _s;
@ -874,14 +884,14 @@ template <class DB> bytes GenericTrieDB<DB>::branch(RLP const& _orig)
if (k.size() == 0) if (k.size() == 0)
{ {
assert(isLeaf(_orig)); assert(isLeaf(_orig));
for (uint i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
r << ""; r << "";
r << _orig[1]; r << _orig[1];
} }
else else
{ {
byte b = k[0]; byte b = k[0];
for (uint i = 0; i < 16; ++i) for (unsigned i = 0; i < 16; ++i)
if (i == b) if (i == b)
if (isLeaf(_orig) || k.size() > 1) if (isLeaf(_orig) || k.size() > 1)
{ {
@ -899,3 +909,5 @@ template <class DB> bytes GenericTrieDB<DB>::branch(RLP const& _orig)
} }
} }
}

7
libethential/Common.cpp

@ -22,11 +22,12 @@
#include "Common.h" #include "Common.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
namespace eth namespace dev
{ {
char const* EthVersion = "0.6.8"; char const* Version = "0.6.8";
} }

19
libethential/Common.h

@ -23,7 +23,7 @@
#pragma once #pragma once
// way to many uint to size_t warnings in 32 bit build // way to many unsigned to size_t warnings in 32 bit build
#ifdef _M_IX86 #ifdef _M_IX86
#pragma warning(disable:4244) #pragma warning(disable:4244)
#endif #endif
@ -43,13 +43,13 @@
using byte = uint8_t; using byte = uint8_t;
// Quote a given token stream to turn it into a string. // Quote a given token stream to turn it into a string.
#define ETH_QUOTED_HELPER(s) #s #define DEV_QUOTED_HELPER(s) #s
#define ETH_QUOTED(s) ETH_QUOTED_HELPER(s) #define DEV_QUOTED(s) DEV_QUOTED_HELPER(s)
namespace eth namespace dev
{ {
extern char const* EthVersion; extern char const* Version;
// Binary data types. // Binary data types.
using bytes = std::vector<byte>; using bytes = std::vector<byte>;
@ -62,8 +62,6 @@ using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backe
using s256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>; using s256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using u160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>; using u160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using s160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>; using s160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using uint = uint64_t;
using sint = int64_t;
using u256s = std::vector<u256>; using u256s = std::vector<u256>;
using u160s = std::vector<u160>; using u160s = std::vector<u160>;
using u256Set = std::set<u256>; using u256Set = std::set<u256>;
@ -98,4 +96,11 @@ inline u256 s2u(s256 _u)
return (u256)(c_end + _u); return (u256)(c_end + _u);
} }
inline unsigned int toLog2(u256 _x)
{
unsigned ret;
for (ret = 0; _x >>= 1; ++ret) {}
return ret;
}
} }

16
libethential/CommonData.cpp

@ -24,9 +24,9 @@
#include <random> #include <random>
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
std::string eth::escaped(std::string const& _s, bool _all) std::string dev::escaped(std::string const& _s, bool _all)
{ {
std::string ret; std::string ret;
ret.reserve(_s.size()); ret.reserve(_s.size());
@ -48,7 +48,7 @@ std::string eth::escaped(std::string const& _s, bool _all)
return ret; return ret;
} }
std::string eth::randomWord() std::string dev::randomWord()
{ {
static std::mt19937_64 s_eng(0); static std::mt19937_64 s_eng(0);
std::string ret(std::uniform_int_distribution<int>(1, 5)(s_eng), ' '); std::string ret(std::uniform_int_distribution<int>(1, 5)(s_eng), ' ');
@ -59,7 +59,7 @@ std::string eth::randomWord()
return ret; return ret;
} }
int eth::fromHex(char _i) int dev::fromHex(char _i)
{ {
if (_i >= '0' && _i <= '9') if (_i >= '0' && _i <= '9')
return _i - '0'; return _i - '0';
@ -70,9 +70,9 @@ int eth::fromHex(char _i)
throw BadHexCharacter(); throw BadHexCharacter();
} }
bytes eth::fromHex(std::string const& _s) bytes dev::fromHex(std::string const& _s)
{ {
uint s = (_s[0] == '0' && _s[1] == 'x') ? 2 : 0; unsigned s = (_s[0] == '0' && _s[1] == 'x') ? 2 : 0;
std::vector<uint8_t> ret; std::vector<uint8_t> ret;
ret.reserve((_s.size() - s + 1) / 2); ret.reserve((_s.size() - s + 1) / 2);
@ -82,7 +82,7 @@ bytes eth::fromHex(std::string const& _s)
ret.push_back(fromHex(_s[s++])); ret.push_back(fromHex(_s[s++]));
} }
catch (...){ ret.push_back(0); } catch (...){ ret.push_back(0); }
for (uint i = s; i < _s.size(); i += 2) for (unsigned i = s; i < _s.size(); i += 2)
try try
{ {
ret.push_back((byte)(fromHex(_s[i]) * 16 + fromHex(_s[i + 1]))); ret.push_back((byte)(fromHex(_s[i]) * 16 + fromHex(_s[i + 1])));
@ -91,7 +91,7 @@ bytes eth::fromHex(std::string const& _s)
return ret; return ret;
} }
bytes eth::asNibbles(std::string const& _s) bytes dev::asNibbles(std::string const& _s)
{ {
std::vector<uint8_t> ret; std::vector<uint8_t> ret;
ret.reserve(_s.size() * 2); ret.reserve(_s.size() * 2);

18
libethential/CommonData.h

@ -30,7 +30,7 @@
#include <string> #include <string>
#include "Common.h" #include "Common.h"
namespace eth namespace dev
{ {
// String conversion functions, mainly to/from hex/nibble/byte representations. // String conversion functions, mainly to/from hex/nibble/byte representations.
@ -79,7 +79,7 @@ bytes asNibbles(std::string const& _s);
/// The size of the collection object will be unchanged. If it is too small, it will not represent the /// The size of the collection object will be unchanged. If it is too small, it will not represent the
/// value properly, if too big then the additional elements will be zeroed out. /// value properly, if too big then the additional elements will be zeroed out.
/// @a _Out will typically be either std::string or bytes. /// @a _Out will typically be either std::string or bytes.
/// @a _T will typically by uint, u160, u256 or bigint. /// @a _T will typically by unsigned, u160, u256 or bigint.
template <class _T, class _Out> template <class _T, class _Out>
inline void toBigEndian(_T _val, _Out& o_out) inline void toBigEndian(_T _val, _Out& o_out)
{ {
@ -89,7 +89,7 @@ inline void toBigEndian(_T _val, _Out& o_out)
/// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value.
/// @a _In will typically be either std::string or bytes. /// @a _In will typically be either std::string or bytes.
/// @a _T will typically by uint, u160, u256 or bigint. /// @a _T will typically by unsigned, u160, u256 or bigint.
template <class _T, class _In> template <class _T, class _In>
inline _T fromBigEndian(_In const& _bytes) inline _T fromBigEndian(_In const& _bytes)
{ {
@ -140,10 +140,10 @@ std::string escaped(std::string const& _s, bool _all = true);
/// @returns the number of elements both @a _t and @a _u share, in order, at the beginning. /// @returns the number of elements both @a _t and @a _u share, in order, at the beginning.
/// @example commonPrefix("Hello world!", "Hello, world!") == 5 /// @example commonPrefix("Hello world!", "Hello, world!") == 5
template <class _T, class _U> template <class _T, class _U>
uint commonPrefix(_T const& _t, _U const& _u) unsigned commonPrefix(_T const& _t, _U const& _u)
{ {
uint s = std::min<uint>(_t.size(), _u.size()); unsigned s = std::min<unsigned>(_t.size(), _u.size());
for (uint i = 0;; ++i) for (unsigned i = 0;; ++i)
if (i == s || _t[i] != _u[i]) if (i == s || _t[i] != _u[i])
return i; return i;
return s; return s;
@ -157,9 +157,9 @@ std::string randomWord();
/// Determine bytes required to encode the given integer value. @returns 0 if @a _i is zero. /// Determine bytes required to encode the given integer value. @returns 0 if @a _i is zero.
template <class _T> template <class _T>
inline uint bytesRequired(_T _i) inline unsigned bytesRequired(_T _i)
{ {
uint i = 0; unsigned i = 0;
for (; _i != 0; ++i, _i >>= 8) {} for (; _i != 0; ++i, _i >>= 8) {}
return i; return i;
} }
@ -167,7 +167,7 @@ inline uint bytesRequired(_T _i)
/// Trims a given number of elements from the front of a collection. /// Trims a given number of elements from the front of a collection.
/// Only works for POD element types. /// Only works for POD element types.
template <class _T> template <class _T>
void trimFront(_T& _t, uint _elements) void trimFront(_T& _t, unsigned _elements)
{ {
static_assert(std::is_pod<typename _T::value_type>::value, ""); static_assert(std::is_pod<typename _T::value_type>::value, "");
memmove(_t.data(), _t.data() + _elements, (_t.size() - _elements) * sizeof(_t[0])); memmove(_t.data(), _t.data() + _elements, (_t.size() - _elements) * sizeof(_t[0]));

8
libethential/CommonIO.cpp

@ -24,9 +24,9 @@
#include <fstream> #include <fstream>
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
string eth::memDump(bytes const& _b, unsigned _w, bool _html) string dev::memDump(bytes const& _b, unsigned _w, bool _html)
{ {
stringstream ret; stringstream ret;
if (_html) if (_html)
@ -57,7 +57,7 @@ string eth::memDump(bytes const& _b, unsigned _w, bool _html)
return ret.str(); return ret.str();
} }
bytes eth::contents(std::string const& _file) bytes dev::contents(std::string const& _file)
{ {
std::ifstream is(_file, std::ifstream::binary); std::ifstream is(_file, std::ifstream::binary);
if (!is) if (!is)
@ -72,7 +72,7 @@ bytes eth::contents(std::string const& _file)
return ret; return ret;
} }
void eth::writeFile(std::string const& _file, bytes const& _data) void dev::writeFile(std::string const& _file, bytes const& _data)
{ {
ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size());
} }

2
libethential/CommonIO.h

@ -37,7 +37,7 @@
#include <iostream> #include <iostream>
#include "Common.h" #include "Common.h"
namespace eth namespace dev
{ {
/// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes.

2
libethential/Exceptions.h

@ -26,7 +26,7 @@
#include "CommonData.h" #include "CommonData.h"
#include "FixedHash.h" #include "FixedHash.h"
namespace eth namespace dev
{ {
class Exception: public std::exception class Exception: public std::exception

4
libethential/FixedHash.cpp

@ -23,6 +23,6 @@
#include "FixedHash.h" #include "FixedHash.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
std::mt19937_64 eth::s_fixedHashEngine(time(0)); std::mt19937_64 dev::s_fixedHashEngine(time(0));

10
libethential/FixedHash.h

@ -28,7 +28,7 @@
#include <algorithm> #include <algorithm>
#include "CommonData.h" #include "CommonData.h"
namespace eth namespace dev
{ {
extern std::mt19937_64 s_fixedHashEngine; extern std::mt19937_64 s_fixedHashEngine;
@ -65,13 +65,13 @@ public:
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
/// Explicitly construct, copying from a byte array. /// Explicitly construct, copying from a byte array.
explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min<uint>(_b.size(), N)); } explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min<unsigned>(_b.size(), N)); }
/// Explicitly construct, copying from a bytes in memory with given pointer. /// Explicitly construct, copying from a bytes in memory with given pointer.
explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); }
/// Explicitly construct, copying from a string. /// Explicitly construct, copying from a string.
explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : eth::asBytes(_s)) {} explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s)) {}
/// Convert to arithmetic type. /// Convert to arithmetic type.
operator Arith() const { return fromBigEndian<Arith>(m_data); } operator Arith() const { return fromBigEndian<Arith>(m_data); }
@ -221,6 +221,6 @@ inline h160 left160(h256 const& _t)
namespace std namespace std
{ {
/// Forward std::hash<eth::h256> to eth::h256::hash. /// Forward std::hash<dev::h256> to dev::h256::hash.
template<> struct hash<eth::h256>: eth::h256::hash {}; template<> struct hash<dev::h256>: dev::h256::hash {};
} }

4
libethential/Guards.cpp

@ -21,9 +21,9 @@
#include "Guards.h" #include "Guards.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
namespace eth namespace dev
{ {
} }

2
libethential/Guards.h

@ -24,7 +24,7 @@
#include <mutex> #include <mutex>
#include <boost/thread.hpp> #include <boost/thread.hpp>
namespace eth namespace dev
{ {
using Mutex = std::mutex; using Mutex = std::mutex;

12
libethential/Log.cpp

@ -24,20 +24,20 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
// Logging // Logging
int eth::g_logVerbosity = 5; int dev::g_logVerbosity = 5;
map<type_info const*, bool> eth::g_logOverride; map<type_info const*, bool> dev::g_logOverride;
ThreadLocalLogName eth::t_logThreadName("main"); ThreadLocalLogName dev::t_logThreadName("main");
// foward declare without all of Windows.h // foward declare without all of Windows.h
#ifdef _WIN32 #ifdef _WIN32
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString); extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString);
#endif #endif
void eth::simpleDebugOut(std::string const& _s, char const*) void dev::simpleDebugOut(std::string const& _s, char const*)
{ {
cout << _s << endl << flush; cout << _s << endl << flush;
@ -50,5 +50,5 @@ void eth::simpleDebugOut(std::string const& _s, char const*)
#endif #endif
} }
std::function<void(std::string const&, char const*)> eth::g_logPost = simpleDebugOut; std::function<void(std::string const&, char const*)> dev::g_logPost = simpleDebugOut;

18
libethential/Log.h

@ -28,7 +28,7 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include "vector_ref.h" #include "vector_ref.h"
namespace eth namespace dev
{ {
/// The null output stream. Used when logging is disabled. /// The null output stream. Used when logging is disabled.
@ -107,19 +107,19 @@ private:
// Simple cout-like stream objects for accessing common log channels. // Simple cout-like stream objects for accessing common log channels.
// Dirties the global namespace, but oh so convenient... // Dirties the global namespace, but oh so convenient...
#define cnote eth::LogOutputStream<eth::NoteChannel, true>() #define cnote dev::LogOutputStream<dev::NoteChannel, true>()
#define cwarn eth::LogOutputStream<eth::WarnChannel, true>() #define cwarn dev::LogOutputStream<dev::WarnChannel, true>()
// Null stream-like objects. // Null stream-like objects.
#define ndebug if (true) {} else eth::NullOutputStream() #define ndebug if (true) {} else dev::NullOutputStream()
#define nlog(X) if (true) {} else eth::NullOutputStream() #define nlog(X) if (true) {} else dev::NullOutputStream()
#define nslog(X) if (true) {} else eth::NullOutputStream() #define nslog(X) if (true) {} else dev::NullOutputStream()
// Kill debugging log channel when we're in release mode. // Kill debugging log channel when we're in release mode.
#if NDEBUG #if NDEBUG
#define cdebug ndebug #define cdebug ndebug
#else #else
#define cdebug eth::LogOutputStream<eth::DebugChannel, true>() #define cdebug dev::LogOutputStream<dev::DebugChannel, true>()
#endif #endif
// Kill all logs when when NLOG is defined. // Kill all logs when when NLOG is defined.
@ -127,8 +127,8 @@ private:
#define clog(X) nlog(X) #define clog(X) nlog(X)
#define cslog(X) nslog(X) #define cslog(X) nslog(X)
#else #else
#define clog(X) eth::LogOutputStream<X, true>() #define clog(X) dev::LogOutputStream<X, true>()
#define cslog(X) eth::LogOutputStream<X, false>() #define cslog(X) dev::LogOutputStream<X, false>()
#endif #endif
} }

42
libethential/RLP.cpp

@ -21,10 +21,10 @@
#include "RLP.h" #include "RLP.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
bytes eth::RLPNull = rlp(""); bytes dev::RLPNull = rlp("");
bytes eth::RLPEmptyList = rlpList(); bytes dev::RLPEmptyList = rlpList();
RLP::iterator& RLP::iterator::operator++() RLP::iterator& RLP::iterator::operator++()
{ {
@ -32,7 +32,7 @@ RLP::iterator& RLP::iterator::operator++()
{ {
m_lastItem.retarget(m_lastItem.next().data(), m_remaining); m_lastItem.retarget(m_lastItem.next().data(), m_remaining);
m_lastItem = m_lastItem.cropped(0, RLP(m_lastItem).actualSize()); m_lastItem = m_lastItem.cropped(0, RLP(m_lastItem).actualSize());
m_remaining -= std::min<uint>(m_remaining, m_lastItem.size()); m_remaining -= std::min<unsigned>(m_remaining, m_lastItem.size());
} }
else else
m_lastItem.retarget(m_lastItem.next().data(), 0); m_lastItem.retarget(m_lastItem.next().data(), 0);
@ -54,7 +54,7 @@ RLP::iterator::iterator(RLP const& _parent, bool _begin)
} }
} }
RLP RLP::operator[](uint _i) const RLP RLP::operator[](unsigned _i) const
{ {
if (_i < m_lastIndex) if (_i < m_lastIndex)
{ {
@ -81,7 +81,7 @@ RLPs RLP::toList() const
return ret; return ret;
} }
eth::uint RLP::actualSize() const unsigned RLP::actualSize() const
{ {
if (isNull()) if (isNull())
return 0; return 0;
@ -118,11 +118,11 @@ bool RLP::isInt() const
return false; return false;
} }
eth::uint RLP::length() const unsigned RLP::length() const
{ {
if (isNull()) if (isNull())
return 0; return 0;
uint ret = 0; unsigned ret = 0;
byte n = m_data[0]; byte n = m_data[0];
if (n < c_rlpDataImmLenStart) if (n < c_rlpDataImmLenStart)
return 1; return 1;
@ -147,12 +147,12 @@ eth::uint RLP::length() const
return ret; return ret;
} }
eth::uint RLP::items() const unsigned RLP::items() const
{ {
if (isList()) if (isList())
{ {
bytesConstRef d = payload().cropped(0, length()); bytesConstRef d = payload().cropped(0, length());
eth::uint i = 0; unsigned i = 0;
for (; d.size(); ++i) for (; d.size(); ++i)
d = d.cropped(RLP(d).actualSize()); d = d.cropped(RLP(d).actualSize());
return i; return i;
@ -160,16 +160,16 @@ eth::uint RLP::items() const
return 0; return 0;
} }
RLPStream& RLPStream::appendRaw(bytesConstRef _s, uint _itemCount) RLPStream& RLPStream::appendRaw(bytesConstRef _s, unsigned _itemCount)
{ {
uint os = m_out.size(); unsigned os = m_out.size();
m_out.resize(os + _s.size()); m_out.resize(os + _s.size());
memcpy(m_out.data() + os, _s.data(), _s.size()); memcpy(m_out.data() + os, _s.data(), _s.size());
noteAppended(_itemCount); noteAppended(_itemCount);
return *this; return *this;
} }
void RLPStream::noteAppended(uint _itemCount) void RLPStream::noteAppended(unsigned _itemCount)
{ {
if (!_itemCount) if (!_itemCount)
return; return;
@ -184,9 +184,9 @@ void RLPStream::noteAppended(uint _itemCount)
{ {
auto p = m_listStack.back().second; auto p = m_listStack.back().second;
m_listStack.pop_back(); m_listStack.pop_back();
uint s = m_out.size() - p; // list size unsigned s = m_out.size() - p; // list size
auto brs = bytesRequired(s); auto brs = bytesRequired(s);
uint encodeSize = s < c_rlpListImmLenCount ? 1 : (1 + brs); unsigned encodeSize = s < c_rlpListImmLenCount ? 1 : (1 + brs);
// cdebug << "s: " << s << ", p: " << p << ", m_out.size(): " << m_out.size() << ", encodeSize: " << encodeSize << " (br: " << brs << ")"; // cdebug << "s: " << s << ", p: " << p << ", m_out.size(): " << m_out.size() << ", encodeSize: " << encodeSize << " (br: " << brs << ")";
auto os = m_out.size(); auto os = m_out.size();
m_out.resize(os + encodeSize); m_out.resize(os + encodeSize);
@ -205,7 +205,7 @@ void RLPStream::noteAppended(uint _itemCount)
} }
} }
RLPStream& RLPStream::appendList(uint _items) RLPStream& RLPStream::appendList(unsigned _items)
{ {
// cdebug << "appendList(" << _items << ")"; // cdebug << "appendList(" << _items << ")";
if (_items) if (_items)
@ -227,7 +227,7 @@ RLPStream& RLPStream::appendList(bytesConstRef _rlp)
RLPStream& RLPStream::append(bytesConstRef _s, bool _compact) RLPStream& RLPStream::append(bytesConstRef _s, bool _compact)
{ {
uint s = _s.size(); unsigned s = _s.size();
byte const* d = _s.data(); byte const* d = _s.data();
if (_compact) if (_compact)
for (unsigned i = 0; i < _s.size() && !*d; ++i, --s, ++d) {} for (unsigned i = 0; i < _s.size() && !*d; ++i, --s, ++d) {}
@ -254,7 +254,7 @@ RLPStream& RLPStream::append(bigint _i)
m_out.push_back((byte)_i); m_out.push_back((byte)_i);
else else
{ {
uint br = bytesRequired(_i); unsigned br = bytesRequired(_i);
if (br < c_rlpDataImmLenCount) if (br < c_rlpDataImmLenCount)
m_out.push_back((byte)(br + c_rlpDataImmLenStart)); m_out.push_back((byte)(br + c_rlpDataImmLenStart));
else else
@ -269,21 +269,21 @@ RLPStream& RLPStream::append(bigint _i)
return *this; return *this;
} }
void RLPStream::pushCount(uint _count, byte _base) void RLPStream::pushCount(unsigned _count, byte _base)
{ {
auto br = bytesRequired(_count); auto br = bytesRequired(_count);
m_out.push_back((byte)(br + _base)); // max 8 bytes. m_out.push_back((byte)(br + _base)); // max 8 bytes.
pushInt(_count, br); pushInt(_count, br);
} }
std::ostream& eth::operator<<(std::ostream& _out, eth::RLP const& _d) std::ostream& dev::operator<<(std::ostream& _out, RLP const& _d)
{ {
if (_d.isNull()) if (_d.isNull())
_out << "null"; _out << "null";
else if (_d.isInt()) else if (_d.isInt())
_out << std::showbase << std::hex << std::nouppercase << _d.toInt<bigint>(RLP::LaisezFaire) << dec; _out << std::showbase << std::hex << std::nouppercase << _d.toInt<bigint>(RLP::LaisezFaire) << dec;
else if (_d.isData()) else if (_d.isData())
_out << eth::escaped(_d.toString(), false); _out << escaped(_d.toString(), false);
else if (_d.isList()) else if (_d.isList())
{ {
_out << "["; _out << "[";

68
libethential/RLP.h

@ -33,16 +33,16 @@
#include <libethential/Exceptions.h> #include <libethential/Exceptions.h>
#include <libethential/FixedHash.h> #include <libethential/FixedHash.h>
namespace eth namespace dev
{ {
class RLP; class RLP;
typedef std::vector<RLP> RLPs; typedef std::vector<RLP> RLPs;
template <class _T> struct intTraits { static const uint maxSize = sizeof(_T); }; template <class _T> struct intTraits { static const unsigned maxSize = sizeof(_T); };
template <> struct intTraits<u160> { static const uint maxSize = 20; }; template <> struct intTraits<u160> { static const unsigned maxSize = 20; };
template <> struct intTraits<u256> { static const uint maxSize = 32; }; template <> struct intTraits<u256> { static const unsigned maxSize = 32; };
template <> struct intTraits<bigint> { static const uint maxSize = ~(uint)0; }; template <> struct intTraits<bigint> { static const unsigned maxSize = ~(unsigned)0; };
static const byte c_rlpMaxLengthBytes = 8; static const byte c_rlpMaxLengthBytes = 8;
static const byte c_rlpDataImmLenStart = 0x80; static const byte c_rlpDataImmLenStart = 0x80;
@ -72,7 +72,7 @@ public:
explicit RLP(bytes const& _d): m_data(&_d) {} explicit RLP(bytes const& _d): m_data(&_d) {}
/// Construct a node to read RLP data in the bytes given. /// Construct a node to read RLP data in the bytes given.
RLP(byte const* _b, uint _s): m_data(bytesConstRef(_b, _s)) {} RLP(byte const* _b, unsigned _s): m_data(bytesConstRef(_b, _s)) {}
/// Construct a node to read RLP data in the string. /// Construct a node to read RLP data in the string.
explicit RLP(std::string const& _s): m_data(bytesConstRef((byte const*)_s.data(), _s.size())) {} explicit RLP(std::string const& _s): m_data(bytesConstRef((byte const*)_s.data(), _s.size())) {}
@ -99,12 +99,12 @@ public:
bool isInt() const; bool isInt() const;
/// @returns the number of items in the list, or zero if it isn't a list. /// @returns the number of items in the list, or zero if it isn't a list.
uint itemCount() const { return isList() ? items() : 0; } unsigned itemCount() const { return isList() ? items() : 0; }
uint itemCountStrict() const { if (!isList()) throw BadCast(); return items(); } unsigned itemCountStrict() const { if (!isList()) throw BadCast(); return items(); }
/// @returns the number of bytes in the data, or zero if it isn't data. /// @returns the number of bytes in the data, or zero if it isn't data.
uint size() const { return isData() ? length() : 0; } unsigned size() const { return isData() ? length() : 0; }
uint sizeStrict() const { if (!isData()) throw BadCast(); return length(); } unsigned sizeStrict() const { if (!isData()) throw BadCast(); return length(); }
/// Equality operators; does best-effort conversion and checks for equality. /// Equality operators; does best-effort conversion and checks for equality.
bool operator==(char const* _s) const { return isData() && toString() == _s; } bool operator==(char const* _s) const { return isData() && toString() == _s; }
@ -113,8 +113,8 @@ public:
bool operator!=(std::string const& _s) const { return isData() && toString() != _s; } bool operator!=(std::string const& _s) const { return isData() && toString() != _s; }
template <unsigned _N> bool operator==(FixedHash<_N> const& _h) const { return isData() && toHash<_N>() == _h; } template <unsigned _N> bool operator==(FixedHash<_N> const& _h) const { return isData() && toHash<_N>() == _h; }
template <unsigned _N> bool operator!=(FixedHash<_N> const& _s) const { return isData() && toHash<_N>() != _s; } template <unsigned _N> bool operator!=(FixedHash<_N> const& _s) const { return isData() && toHash<_N>() != _s; }
bool operator==(uint const& _i) const { return isInt() && toInt<uint>() == _i; } bool operator==(unsigned const& _i) const { return isInt() && toInt<unsigned>() == _i; }
bool operator!=(uint const& _i) const { return isInt() && toInt<uint>() != _i; } bool operator!=(unsigned const& _i) const { return isInt() && toInt<unsigned>() != _i; }
bool operator==(u256 const& _i) const { return isInt() && toInt<u256>() == _i; } bool operator==(u256 const& _i) const { return isInt() && toInt<u256>() == _i; }
bool operator!=(u256 const& _i) const { return isInt() && toInt<u256>() != _i; } bool operator!=(u256 const& _i) const { return isInt() && toInt<u256>() != _i; }
bool operator==(bigint const& _i) const { return isInt() && toInt<bigint>() == _i; } bool operator==(bigint const& _i) const { return isInt() && toInt<bigint>() == _i; }
@ -123,7 +123,7 @@ public:
/// Subscript operator. /// Subscript operator.
/// @returns the list item @a _i if isList() and @a _i < listItems(), or RLP() otherwise. /// @returns the list item @a _i if isList() and @a _i < listItems(), or RLP() otherwise.
/// @note if used to access items in ascending order, this is efficient. /// @note if used to access items in ascending order, this is efficient.
RLP operator[](uint _i) const; RLP operator[](unsigned _i) const;
typedef RLP element_type; typedef RLP element_type;
@ -146,7 +146,7 @@ public:
iterator() {} iterator() {}
iterator(RLP const& _parent, bool _begin); iterator(RLP const& _parent, bool _begin);
uint m_remaining = 0; unsigned m_remaining = 0;
bytesConstRef m_lastItem; bytesConstRef m_lastItem;
}; };
@ -160,7 +160,7 @@ public:
explicit operator std::string() const { return toString(); } explicit operator std::string() const { return toString(); }
explicit operator RLPs() const { return toList(); } explicit operator RLPs() const { return toList(); }
explicit operator byte() const { return toInt<byte>(); } explicit operator byte() const { return toInt<byte>(); }
explicit operator uint() const { return toInt<uint>(); } explicit operator unsigned() const { return toInt<unsigned>(); }
explicit operator u256() const { return toInt<u256>(); } explicit operator u256() const { return toInt<u256>(); }
explicit operator bigint() const { return toInt<bigint>(); } explicit operator bigint() const { return toInt<bigint>(); }
template <unsigned _N> explicit operator FixedHash<_N>() const { return toHash<FixedHash<_N>>(); } template <unsigned _N> explicit operator FixedHash<_N>() const { return toHash<FixedHash<_N>>(); }
@ -181,7 +181,7 @@ public:
template <class T> std::vector<T> toVector() const { std::vector<T> ret; if (isList()) { ret.reserve(itemCount()); for (auto const& i: *this) ret.push_back((T)i); } return ret; } template <class T> std::vector<T> toVector() const { std::vector<T> ret; if (isList()) { ret.reserve(itemCount()); for (auto const& i: *this) ret.push_back((T)i); } return ret; }
template <class T> std::set<T> toSet() const { std::set<T> ret; if (isList()) { for (auto const& i: *this) ret.insert((T)i); } return ret; } template <class T> std::set<T> toSet() const { std::set<T> ret; if (isList()) { for (auto const& i: *this) ret.insert((T)i); } return ret; }
template <class T, class U> std::pair<T, U> toPair() const { std::pair<T, U> ret; if (isList()) { ret.first = (T)((*this)[0]); ret.second = (U)((*this)[1]); } return ret; } template <class T, class U> std::pair<T, U> toPair() const { std::pair<T, U> ret; if (isList()) { ret.first = (T)((*this)[0]); ret.second = (U)((*this)[1]); } return ret; }
template <class T, size_t N> std::array<T, N> toArray() const { if (itemCount() != N || !isList()) throw BadCast(); std::array<T, N> ret; for (uint i = 0; i < N; ++i) ret[i] = (T)operator[](i); return ret; } template <class T, size_t N> std::array<T, N> toArray() const { if (itemCount() != N || !isList()) throw BadCast(); std::array<T, N> ret; for (unsigned i = 0; i < N; ++i) ret[i] = (T)operator[](i); return ret; }
/// Int conversion flags /// Int conversion flags
enum enum
@ -194,7 +194,7 @@ public:
}; };
/// Converts to int of type given; if isString(), decodes as big-endian bytestream. @returns 0 if not an int or string. /// Converts to int of type given; if isString(), decodes as big-endian bytestream. @returns 0 if not an int or string.
template <class _T = uint> _T toInt(int _flags = Strict) const template <class _T = unsigned> _T toInt(int _flags = Strict) const
{ {
if ((!isInt() && !(_flags & AllowNonCanon)) || isList() || isNull()) if ((!isInt() && !(_flags & AllowNonCanon)) || isList() || isNull())
if (_flags & ThrowOnFail) if (_flags & ThrowOnFail)
@ -237,27 +237,27 @@ public:
/// @returns the theoretical size of this item. /// @returns the theoretical size of this item.
/// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work. /// @note Under normal circumstances, is equivalent to m_data.size() - use that unless you know it won't work.
uint actualSize() const; unsigned actualSize() const;
private: private:
/// Single-byte data payload. /// Single-byte data payload.
bool isSingleByte() const { return !isNull() && m_data[0] < c_rlpDataImmLenStart; } bool isSingleByte() const { return !isNull() && m_data[0] < c_rlpDataImmLenStart; }
/// @returns the bytes used to encode the length of the data. Valid for all types. /// @returns the bytes used to encode the length of the data. Valid for all types.
uint lengthSize() const { if (isData() && m_data[0] > c_rlpDataIndLenZero) return m_data[0] - c_rlpDataIndLenZero; if (isList() && m_data[0] > c_rlpListIndLenZero) return m_data[0] - c_rlpListIndLenZero; return 0; } unsigned lengthSize() const { if (isData() && m_data[0] > c_rlpDataIndLenZero) return m_data[0] - c_rlpDataIndLenZero; if (isList() && m_data[0] > c_rlpListIndLenZero) return m_data[0] - c_rlpListIndLenZero; return 0; }
/// @returns the size in bytes of the payload, as given by the RLP as opposed to as inferred from m_data. /// @returns the size in bytes of the payload, as given by the RLP as opposed to as inferred from m_data.
uint length() const; unsigned length() const;
/// @returns the number of data items. /// @returns the number of data items.
uint items() const; unsigned items() const;
/// Our byte data. /// Our byte data.
bytesConstRef m_data; bytesConstRef m_data;
/// The list-indexing cache. /// The list-indexing cache.
mutable uint m_lastIndex = (uint)-1; mutable unsigned m_lastIndex = (unsigned)-1;
mutable uint m_lastEnd = 0; mutable unsigned m_lastEnd = 0;
mutable bytesConstRef m_lastItem; mutable bytesConstRef m_lastItem;
}; };
@ -271,12 +271,12 @@ public:
RLPStream() {} RLPStream() {}
/// Initializes the RLPStream as a list of @a _listItems items. /// Initializes the RLPStream as a list of @a _listItems items.
explicit RLPStream(uint _listItems) { appendList(_listItems); } explicit RLPStream(unsigned _listItems) { appendList(_listItems); }
~RLPStream() {} ~RLPStream() {}
/// Append given datum to the byte stream. /// Append given datum to the byte stream.
RLPStream& append(uint _s) { return append(bigint(_s)); } RLPStream& append(unsigned _s) { return append(bigint(_s)); }
RLPStream& append(u160 _s) { return append(bigint(_s)); } RLPStream& append(u160 _s) { return append(bigint(_s)); }
RLPStream& append(u256 _s) { return append(bigint(_s)); } RLPStream& append(u256 _s) { return append(bigint(_s)); }
RLPStream& append(bigint _s); RLPStream& append(bigint _s);
@ -287,7 +287,7 @@ public:
template <unsigned N> RLPStream& append(FixedHash<N> _s, bool _compact = false, bool _allOrNothing = false) { return _allOrNothing && !_s ? append(bytesConstRef()) : append(_s.ref(), _compact); } template <unsigned N> RLPStream& append(FixedHash<N> _s, bool _compact = false, bool _allOrNothing = false) { return _allOrNothing && !_s ? append(bytesConstRef()) : append(_s.ref(), _compact); }
/// Appends an arbitrary RLP fragment - this *must* be a single item. /// Appends an arbitrary RLP fragment - this *must* be a single item.
RLPStream& append(RLP const& _rlp, uint _itemCount = 1) { return appendRaw(_rlp.data(), _itemCount); } RLPStream& append(RLP const& _rlp, unsigned _itemCount = 1) { return appendRaw(_rlp.data(), _itemCount); }
/// Appends a sequence of data to the stream as a list. /// Appends a sequence of data to the stream as a list.
template <class _T> RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); } template <class _T> RLPStream& append(std::vector<_T> const& _s) { return appendVector(_s); }
@ -297,14 +297,14 @@ public:
template <class T, class U> RLPStream& append(std::pair<T, U> const& _s) { appendList(2); append(_s.first); append(_s.second); return *this; } template <class T, class U> RLPStream& append(std::pair<T, U> const& _s) { appendList(2); append(_s.first); append(_s.second); return *this; }
/// Appends a list. /// Appends a list.
RLPStream& appendList(uint _items); RLPStream& appendList(unsigned _items);
RLPStream& appendList(bytesConstRef _rlp); RLPStream& appendList(bytesConstRef _rlp);
RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); } RLPStream& appendList(bytes const& _rlp) { return appendList(&_rlp); }
RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); } RLPStream& appendList(RLPStream const& _s) { return appendList(&_s.out()); }
/// Appends raw (pre-serialised) RLP data. Use with caution. /// Appends raw (pre-serialised) RLP data. Use with caution.
RLPStream& appendRaw(bytesConstRef _rlp, uint _itemCount = 1); RLPStream& appendRaw(bytesConstRef _rlp, unsigned _itemCount = 1);
RLPStream& appendRaw(bytes const& _rlp, uint _itemCount = 1) { return appendRaw(&_rlp, _itemCount); } RLPStream& appendRaw(bytes const& _rlp, unsigned _itemCount = 1) { return appendRaw(&_rlp, _itemCount); }
/// Shift operators for appending data items. /// Shift operators for appending data items.
template <class T> RLPStream& operator<<(T _data) { return append(_data); } template <class T> RLPStream& operator<<(T _data) { return append(_data); }
@ -319,14 +319,14 @@ public:
void swapOut(bytes& _dest) { assert(m_listStack.empty()); swap(m_out, _dest); } void swapOut(bytes& _dest) { assert(m_listStack.empty()); swap(m_out, _dest); }
private: private:
void noteAppended(uint _itemCount = 1); void noteAppended(unsigned _itemCount = 1);
/// Push the node-type byte (using @a _base) along with the item count @a _count. /// Push the node-type byte (using @a _base) along with the item count @a _count.
/// @arg _count is number of characters for strings, data-bytes for ints, or items for lists. /// @arg _count is number of characters for strings, data-bytes for ints, or items for lists.
void pushCount(uint _count, byte _offset); void pushCount(unsigned _count, byte _offset);
/// Push an integer as a raw big-endian byte-stream. /// Push an integer as a raw big-endian byte-stream.
template <class _T> void pushInt(_T _i, uint _br) template <class _T> void pushInt(_T _i, unsigned _br)
{ {
m_out.resize(m_out.size() + _br); m_out.resize(m_out.size() + _br);
byte* b = &m_out.back(); byte* b = &m_out.back();
@ -337,7 +337,7 @@ private:
/// Our output byte stream. /// Our output byte stream.
bytes m_out; bytes m_out;
std::vector<std::pair<uint, uint>> m_listStack; std::vector<std::pair<unsigned, unsigned>> m_listStack;
}; };
template <class _T> void rlpListAux(RLPStream& _out, _T _t) { _out << _t; } template <class _T> void rlpListAux(RLPStream& _out, _T _t) { _out << _t; }
@ -362,6 +362,6 @@ extern bytes RLPNull;
extern bytes RLPEmptyList; extern bytes RLPEmptyList;
/// Human readable version of RLP. /// Human readable version of RLP.
std::ostream& operator<<(std::ostream& _out, eth::RLP const& _d); std::ostream& operator<<(std::ostream& _out, dev::RLP const& _d);
} }

12
libethential/vector_ref.h

@ -5,12 +5,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#pragma warning(push) namespace dev
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
namespace eth
{ {
template <class _T> template <class _T>
@ -26,8 +21,9 @@ public:
vector_ref(std::string* _data): m_data((_T*)_data->data()), m_count(_data->size() / sizeof(_T)) {} vector_ref(std::string* _data): m_data((_T*)_data->data()), m_count(_data->size() / sizeof(_T)) {}
vector_ref(typename std::conditional<std::is_const<_T>::value, std::vector<typename std::remove_const<_T>::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} vector_ref(typename std::conditional<std::is_const<_T>::value, std::vector<typename std::remove_const<_T>::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {}
vector_ref(typename std::conditional<std::is_const<_T>::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {} vector_ref(typename std::conditional<std::is_const<_T>::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {}
#ifdef STORAGE_LEVELDB_INCLUDE_DB_H_
vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {} vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {}
#endif
explicit operator bool() const { return m_data && m_count; } explicit operator bool() const { return m_data && m_count; }
bool contentsEqual(std::vector<mutable_value_type> const& _c) const { return _c.size() == m_count && !memcmp(_c.data(), m_data, m_count); } bool contentsEqual(std::vector<mutable_value_type> const& _c) const { return _c.size() == m_count && !memcmp(_c.data(), m_data, m_count); }
@ -56,7 +52,9 @@ public:
bool operator==(vector_ref<_T> const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; } bool operator==(vector_ref<_T> const& _cmp) const { return m_data == _cmp.m_data && m_count == _cmp.m_count; }
bool operator!=(vector_ref<_T> const& _cmp) const { return !operator==(_cmp); } bool operator!=(vector_ref<_T> const& _cmp) const { return !operator==(_cmp); }
#ifdef STORAGE_LEVELDB_INCLUDE_DB_H_
operator leveldb::Slice() const { return leveldb::Slice((char const*)m_data, m_count * sizeof(_T)); } operator leveldb::Slice() const { return leveldb::Slice((char const*)m_data, m_count * sizeof(_T)); }
#endif
void reset() { m_data = nullptr; m_count = 0; } void reset() { m_data = nullptr; m_count = 0; }

13
libethereum/AccountDiff.cpp

@ -23,7 +23,8 @@
#include <libethential/CommonIO.h> #include <libethential/CommonIO.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
AccountChange AccountDiff::changeType() const AccountChange AccountDiff::changeType() const
{ {
@ -39,7 +40,9 @@ char const* AccountDiff::lead() const
return exist ? exist.from() ? "XXX" : "+++" : (bn && sc) ? "***" : bn ? " * " : sc ? "* *" : " "; return exist ? exist.from() ? "XXX" : "+++" : (bn && sc) ? "***" : bn ? " * " : sc ? "* *" : " ";
} }
std::ostream& eth::operator<<(std::ostream& _out, AccountDiff const& _s) namespace dev {
std::ostream& operator<<(std::ostream& _out, dev::eth::AccountDiff const& _s)
{ {
if (!_s.exist.to()) if (!_s.exist.to())
return _out; return _out;
@ -68,10 +71,14 @@ std::ostream& eth::operator<<(std::ostream& _out, AccountDiff const& _s)
return _out; return _out;
} }
std::ostream& eth::operator<<(std::ostream& _out, StateDiff const& _s) std::ostream& operator<<(std::ostream& _out, dev::eth::StateDiff const& _s)
{ {
_out << _s.accounts.size() << " accounts changed:" << endl; _out << _s.accounts.size() << " accounts changed:" << endl;
dev::eth::AccountDiff d;
_out << d;
for (auto const& i: _s.accounts) for (auto const& i: _s.accounts)
_out << i.second.lead() << " " << i.first << ": " << i.second << endl; _out << i.second.lead() << " " << i.first << ": " << i.second << endl;
return _out; return _out;
} }
}

9
libethereum/AccountDiff.h

@ -24,6 +24,8 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -65,9 +67,10 @@ struct StateDiff
std::map<Address, AccountDiff> accounts; std::map<Address, AccountDiff> accounts;
}; };
std::ostream& operator<<(std::ostream& _out, StateDiff const& _s);
std::ostream& operator<<(std::ostream& _out, AccountDiff const& _s);
} }
std::ostream& operator<<(std::ostream& _out, dev::eth::StateDiff const& _s);
std::ostream& operator<<(std::ostream& _out, dev::eth::AccountDiff const& _s);
}

3
libethereum/AddressState.cpp

@ -22,7 +22,8 @@
#include "AddressState.h" #include "AddressState.h"
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
#pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-variable"
namespace { char dummy; }; namespace { char dummy; };

4
libethereum/AddressState.h

@ -25,6 +25,8 @@
#include <libethential/RLP.h> #include <libethential/RLP.h>
#include <libethcore/SHA3.h> #include <libethcore/SHA3.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -78,5 +80,5 @@ private:
}; };
} }
}

25
libethereum/BlockChain.cpp

@ -31,11 +31,12 @@
#include "State.h" #include "State.h"
#include "Defaults.h" #include "Defaults.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
#define ETH_CATCH 1 #define ETH_CATCH 1
std::ostream& eth::operator<<(std::ostream& _out, BlockChain const& _bc) std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc)
{ {
string cmp = toBigEndianString(_bc.currentHash()); string cmp = toBigEndianString(_bc.currentHash());
auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions); auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions);
@ -49,7 +50,7 @@ std::ostream& eth::operator<<(std::ostream& _out, BlockChain const& _bc)
return _out; return _out;
} }
std::map<Address, AddressState> const& eth::genesisState() std::map<Address, AddressState> const& dev::eth::genesisState()
{ {
static std::map<Address, AddressState> s_ret; static std::map<Address, AddressState> s_ret;
if (s_ret.empty()) if (s_ret.empty())
@ -71,7 +72,7 @@ std::map<Address, AddressState> const& eth::genesisState()
BlockInfo* BlockChain::s_genesis = nullptr; BlockInfo* BlockChain::s_genesis = nullptr;
boost::shared_mutex BlockChain::x_genesis; boost::shared_mutex BlockChain::x_genesis;
ldb::Slice eth::toSlice(h256 _h, unsigned _sub) ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub)
{ {
#if ALL_COMPILERS_ARE_CPP11_COMPLIANT #if ALL_COMPILERS_ARE_CPP11_COMPLIANT
static thread_local h256 h = _h ^ h256(u256(_sub)); static thread_local h256 h = _h ^ h256(u256(_sub));
@ -95,12 +96,12 @@ bytes BlockChain::createGenesisBlock()
MemoryDB db; MemoryDB db;
TrieDB<Address, MemoryDB> state(&db); TrieDB<Address, MemoryDB> state(&db);
state.init(); state.init();
eth::commit(genesisState(), db, state); dev::eth::commit(genesisState(), db, state);
stateRoot = state.root(); stateRoot = state.root();
} }
block.appendList(13) << h256() << sha3EmptyList << h160(); block.appendList(13) << h256() << sha3EmptyList << h160();
block.append(stateRoot, false, true) << bytes() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (uint)0 << string() << sha3(bytes(1, 42)); block.append(stateRoot, false, true) << bytes() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42));
block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList);
block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList);
return block.out(); return block.out();
@ -135,7 +136,7 @@ BlockChain::BlockChain(std::string _path, bool _killExisting)
// Insert details of genesis block. // Insert details of genesis block.
m_details[m_genesisHash] = BlockDetails(0, c_genesisDifficulty, h256(), {}, h256()); m_details[m_genesisHash] = BlockDetails(0, c_genesisDifficulty, h256(), {}, h256());
auto r = m_details[m_genesisHash].rlp(); auto r = m_details[m_genesisHash].rlp();
m_extrasDB->Put(m_writeOptions, ldb::Slice((char const*)&m_genesisHash, 32), (ldb::Slice)eth::ref(r)); m_extrasDB->Put(m_writeOptions, ldb::Slice((char const*)&m_genesisHash, 32), (ldb::Slice)dev::ref(r));
} }
checkConsistency(); checkConsistency();
@ -287,7 +288,7 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
// All ok - insert into DB // All ok - insert into DB
{ {
WriteGuard l(x_details); WriteGuard l(x_details);
m_details[newHash] = BlockDetails((uint)pd.number + 1, td, bi.parentHash, {}, b); m_details[newHash] = BlockDetails((unsigned)pd.number + 1, td, bi.parentHash, {}, b);
m_details[bi.parentHash].children.push_back(newHash); m_details[bi.parentHash].children.push_back(newHash);
} }
{ {
@ -299,10 +300,10 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
m_traces[newHash] = bt; m_traces[newHash] = bt;
} }
m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)eth::ref(m_details[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)eth::ref(m_details[bi.parentHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(newHash, 1), (ldb::Slice)eth::ref(m_blooms[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 1), (ldb::Slice)dev::ref(m_blooms[newHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(newHash, 2), (ldb::Slice)eth::ref(m_traces[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 2), (ldb::Slice)dev::ref(m_traces[newHash].rlp()));
m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block));
#if ETH_PARANOIA #if ETH_PARANOIA

12
libethereum/BlockChain.h

@ -21,6 +21,11 @@
#pragma once #pragma once
#pragma warning(push)
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
#include <mutex> #include <mutex>
#include <libethential/Log.h> #include <libethential/Log.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
@ -31,6 +36,8 @@
#include "BlockQueue.h" #include "BlockQueue.h"
namespace ldb = leveldb; namespace ldb = leveldb;
namespace dev
{
namespace eth namespace eth
{ {
@ -95,8 +102,8 @@ public:
bytes block() const { return block(currentHash()); } bytes block() const { return block(currentHash()); }
/// Get a number for the given hash (or the most recent mined if none given). Thread-safe. /// Get a number for the given hash (or the most recent mined if none given). Thread-safe.
uint number(h256 _hash) const { return details(_hash).number; } unsigned number(h256 _hash) const { return details(_hash).number; }
uint number() const { return number(currentHash()); } unsigned number() const { return number(currentHash()); }
/// Get a given block (RLP format). Thread-safe. /// Get a given block (RLP format). Thread-safe.
h256 currentHash() const { ReadGuard l(x_lastBlockHash); return m_lastBlockHash; } h256 currentHash() const { ReadGuard l(x_lastBlockHash); return m_lastBlockHash; }
@ -195,3 +202,4 @@ private:
std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc); std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc);
} }
}

5
libethereum/BlockDetails.cpp

@ -23,11 +23,12 @@
#include <libethential/Common.h> #include <libethential/Common.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
BlockDetails::BlockDetails(RLP const& _r) BlockDetails::BlockDetails(RLP const& _r)
{ {
number = _r[0].toInt<uint>(); number = _r[0].toInt<unsigned>();
totalDifficulty = _r[1].toInt<u256>(); totalDifficulty = _r[1].toInt<u256>();
parent = _r[2].toHash<h256>(); parent = _r[2].toHash<h256>();
children = _r[3].toVector<h256>(); children = _r[3].toVector<h256>();

12
libethereum/BlockDetails.h

@ -21,25 +21,32 @@
#pragma once #pragma once
#pragma warning(push)
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
#include <libethential/Log.h> #include <libethential/Log.h>
#include <libethential/RLP.h> #include <libethential/RLP.h>
#include "Manifest.h" #include "Manifest.h"
namespace ldb = leveldb; namespace ldb = leveldb;
namespace dev
{
namespace eth namespace eth
{ {
struct BlockDetails struct BlockDetails
{ {
BlockDetails(): number(0), totalDifficulty(0) {} BlockDetails(): number(0), totalDifficulty(0) {}
BlockDetails(uint _n, u256 _tD, h256 _p, h256s _c, h256 _bloom): number(_n), totalDifficulty(_tD), parent(_p), children(_c), bloom(_bloom) {} BlockDetails(unsigned _n, u256 _tD, h256 _p, h256s _c, h256 _bloom): number(_n), totalDifficulty(_tD), parent(_p), children(_c), bloom(_bloom) {}
BlockDetails(RLP const& _r); BlockDetails(RLP const& _r);
bytes rlp() const; bytes rlp() const;
bool isNull() const { return !totalDifficulty; } bool isNull() const { return !totalDifficulty; }
explicit operator bool() const { return !isNull(); } explicit operator bool() const { return !isNull(); }
uint number; // TODO: remove? unsigned number; // TODO: remove?
u256 totalDifficulty; u256 totalDifficulty;
h256 parent; h256 parent;
h256s children; h256s children;
@ -74,3 +81,4 @@ static const BlockBlooms NullBlockBlooms;
static const BlockTraces NullBlockTraces; static const BlockTraces NullBlockTraces;
} }
}

3
libethereum/BlockQueue.cpp

@ -26,7 +26,8 @@
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
#include "BlockChain.h" #include "BlockChain.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc) bool BlockQueue::import(bytesConstRef _block, BlockChain const& _bc)
{ {

5
libethereum/BlockQueue.h

@ -26,6 +26,8 @@
#include "libethcore/CommonEth.h" #include "libethcore/CommonEth.h"
#include <libethential/Guards.h> #include <libethential/Guards.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -67,5 +69,4 @@ private:
}; };
} }
}

3
libethereum/Client.cpp

@ -29,7 +29,8 @@
#include "Defaults.h" #include "Defaults.h"
#include "EthereumHost.h" #include "EthereumHost.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
using namespace p2p; using namespace p2p;
VersionChecker::VersionChecker(string const& _dbPath): VersionChecker::VersionChecker(string const& _dbPath):

28
libethereum/Client.h

@ -40,6 +40,8 @@
#include "MessageFilter.h" #include "MessageFilter.h"
#include "Miner.h" #include "Miner.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -94,13 +96,13 @@ struct ClientWatch
}; };
struct WatchChannel: public LogChannel { static const char* name() { return "(o)"; } static const int verbosity = 7; }; struct WatchChannel: public LogChannel { static const char* name() { return "(o)"; } static const int verbosity = 7; };
#define cwatch eth::LogOutputStream<eth::WatchChannel, true>() #define cwatch dev::LogOutputStream<dev::eth::WatchChannel, true>()
struct WorkInChannel: public LogChannel { static const char* name() { return ">W>"; } static const int verbosity = 16; }; struct WorkInChannel: public LogChannel { static const char* name() { return ">W>"; } static const int verbosity = 16; };
struct WorkOutChannel: public LogChannel { static const char* name() { return "<W<"; } static const int verbosity = 16; }; struct WorkOutChannel: public LogChannel { static const char* name() { return "<W<"; } static const int verbosity = 16; };
struct WorkChannel: public LogChannel { static const char* name() { return "-W-"; } static const int verbosity = 16; }; struct WorkChannel: public LogChannel { static const char* name() { return "-W-"; } static const int verbosity = 16; };
#define cwork eth::LogOutputStream<eth::WorkChannel, true>() #define cwork dev::LogOutputStream<dev::eth::WorkChannel, true>()
#define cworkin eth::LogOutputStream<eth::WorkInChannel, true>() #define cworkin dev::LogOutputStream<dev::eth::WorkInChannel, true>()
#define cworkout eth::LogOutputStream<eth::WorkOutChannel, true>() #define cworkout dev::LogOutputStream<dev::eth::WorkOutChannel, true>()
/** /**
* @brief Main API hub for interfacing with Ethereum. * @brief Main API hub for interfacing with Ethereum.
@ -176,19 +178,19 @@ public:
std::vector<Address> addresses(int _block) const; std::vector<Address> addresses(int _block) const;
/// Get the fee associated for a transaction with the given data. /// Get the fee associated for a transaction with the given data.
static u256 txGas(uint _dataCount, u256 _gas = 0) { return c_txDataGas * _dataCount + c_txGas + _gas; } static u256 txGas(unsigned _dataCount, u256 _gas = 0) { return c_txDataGas * _dataCount + c_txGas + _gas; }
/// Get the remaining gas limit in this block. /// Get the remaining gas limit in this block.
u256 gasLimitRemaining() const { return m_postMine.gasLimitRemaining(); } u256 gasLimitRemaining() const { return m_postMine.gasLimitRemaining(); }
// [PRIVATE API - only relevant for base clients, not available in general] // [PRIVATE API - only relevant for base clients, not available in general]
eth::State state(unsigned _txi, h256 _block) const; dev::eth::State state(unsigned _txi, h256 _block) const;
eth::State state(h256 _block) const; dev::eth::State state(h256 _block) const;
eth::State state(unsigned _txi) const; dev::eth::State state(unsigned _txi) const;
/// Get the object representing the current state of Ethereum. /// Get the object representing the current state of Ethereum.
eth::State postState() const { ReadGuard l(x_stateDB); return m_postMine; } dev::eth::State postState() const { ReadGuard l(x_stateDB); return m_postMine; }
/// Get the object representing the current canonical blockchain. /// Get the object representing the current canonical blockchain.
BlockChain const& blockChain() const { return m_bc; } BlockChain const& blockChain() const { return m_bc; }
@ -325,10 +327,13 @@ private:
class Watch; class Watch;
}
} }
namespace std { void swap(eth::Watch& _a, eth::Watch& _b); } namespace std { void swap(dev::eth::Watch& _a, dev::eth::Watch& _b); }
namespace dev
{
namespace eth namespace eth
{ {
@ -351,12 +356,13 @@ private:
unsigned m_id; unsigned m_id;
}; };
}
} }
namespace std namespace std
{ {
inline void swap(eth::Watch& _a, eth::Watch& _b) inline void swap(dev::eth::Watch& _a, dev::eth::Watch& _b)
{ {
swap(_a.m_c, _b.m_c); swap(_a.m_c, _b.m_c);
swap(_a.m_id, _b.m_id); swap(_a.m_id, _b.m_id);

3
libethereum/CommonNet.cpp

@ -21,4 +21,5 @@
#include "CommonNet.h" #include "CommonNet.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;

11
libethereum/CommonNet.h

@ -28,13 +28,15 @@
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethential/Log.h> #include <libethential/Log.h>
namespace dev
{
namespace eth namespace eth
{ {
static const eth::uint c_maxHashes = 32; ///< Maximum number of hashes BlockHashes will ever send. static const unsigned c_maxHashes = 32; ///< Maximum number of hashes BlockHashes will ever send.
static const eth::uint c_maxHashesAsk = 32; ///< Maximum number of hashes GetBlockHashes will ever ask for. static const unsigned c_maxHashesAsk = 32; ///< Maximum number of hashes GetBlockHashes will ever ask for.
static const eth::uint c_maxBlocks = 16; ///< Maximum number of blocks Blocks will ever send. static const unsigned c_maxBlocks = 16; ///< Maximum number of blocks Blocks will ever send.
static const eth::uint c_maxBlocksAsk = 16; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain). static const unsigned c_maxBlocksAsk = 16; ///< Maximum number of blocks we ask to receive in Blocks (when using GetChain).
class OverlayDB; class OverlayDB;
class BlockChain; class BlockChain;
@ -54,3 +56,4 @@ enum EthereumPacket
}; };
} }
}

3
libethereum/Defaults.cpp

@ -23,7 +23,8 @@
#include <libethcore/FileSystem.h> #include <libethcore/FileSystem.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
Defaults* Defaults::s_this = nullptr; Defaults* Defaults::s_this = nullptr;

3
libethereum/Defaults.h

@ -23,6 +23,8 @@
#include <libethential/Common.h> #include <libethential/Common.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -45,3 +47,4 @@ private:
}; };
} }
}

5
libethereum/EthereumHost.cpp

@ -35,7 +35,8 @@
#include "BlockQueue.h" #include "BlockQueue.h"
#include "EthereumPeer.h" #include "EthereumPeer.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
using namespace p2p; using namespace p2p;
EthereumHost::EthereumHost(BlockChain const& _ch, u256 _networkId): EthereumHost::EthereumHost(BlockChain const& _ch, u256 _networkId):
@ -139,7 +140,7 @@ void EthereumHost::maintainTransactions(TransactionQueue& _tq, h256 _currentHash
{ {
auto ep = p->cap<EthereumPeer>(); auto ep = p->cap<EthereumPeer>();
bytes b; bytes b;
uint n = 0; unsigned n = 0;
for (auto const& i: _tq.transactions()) for (auto const& i: _tq.transactions())
if ((!m_transactionsSent.count(i.first) && !ep->m_knownTransactions.count(i.first)) || ep->m_requireTransactions || resendAll) if ((!m_transactionsSent.count(i.first) && !ep->m_knownTransactions.count(i.first)) || ep->m_requireTransactions || resendAll)
{ {

7
libethereum/EthereumHost.h

@ -34,10 +34,14 @@
#include "CommonNet.h" #include "CommonNet.h"
#include "EthereumPeer.h" #include "EthereumPeer.h"
namespace eth namespace dev
{ {
class RLPStream; class RLPStream;
namespace eth
{
class TransactionQueue; class TransactionQueue;
class BlockQueue; class BlockQueue;
@ -103,3 +107,4 @@ private:
}; };
} }
}

9
libethereum/EthereumPeer.cpp

@ -28,10 +28,11 @@
#include "BlockChain.h" #include "BlockChain.h"
#include "EthereumHost.h" #include "EthereumHost.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
using namespace p2p; using namespace p2p;
#define clogS(X) eth::LogOutputStream<X, true>(false) << "| " << std::setw(2) << session()->socketId() << "] " #define clogS(X) dev::LogOutputStream<X, true>(false) << "| " << std::setw(2) << session()->socketId() << "] "
EthereumPeer::EthereumPeer(Session* _s, HostCapabilityFace* _h): EthereumPeer::EthereumPeer(Session* _s, HostCapabilityFace* _h):
Capability(_s, _h) Capability(_s, _h)
@ -73,7 +74,7 @@ void EthereumPeer::startInitialSync()
} }
h256 c = host()->m_chain->currentHash(); h256 c = host()->m_chain->currentHash();
uint n = host()->m_chain->number(); unsigned n = host()->m_chain->number();
u256 td = max(host()->m_chain->details().totalDifficulty, host()->m_totalDifficultyOfNeeded); u256 td = max(host()->m_chain->details().totalDifficulty, host()->m_totalDifficultyOfNeeded);
clogS(NetAllDetail) << "Initial sync. Latest:" << c.abridged() << ", number:" << n << ", TD: max(" << host()->m_chain->details().totalDifficulty << "," << host()->m_totalDifficultyOfNeeded << ") versus " << m_totalDifficulty; clogS(NetAllDetail) << "Initial sync. Latest:" << c.abridged() << ", number:" << n << ", TD: max(" << host()->m_chain->details().totalDifficulty << "," << host()->m_totalDifficultyOfNeeded << ") versus " << m_totalDifficulty;
@ -123,7 +124,7 @@ bool EthereumPeer::interpret(RLP const& _r)
{ {
case StatusPacket: case StatusPacket:
{ {
m_protocolVersion = _r[1].toInt<uint>(); m_protocolVersion = _r[1].toInt<unsigned>();
m_networkId = _r[2].toInt<u256>(); m_networkId = _r[2].toInt<u256>();
m_totalDifficulty = _r[3].toInt<u256>(); m_totalDifficulty = _r[3].toInt<u256>();
m_latestHash = _r[4].toHash<h256>(); m_latestHash = _r[4].toHash<h256>();

5
libethereum/EthereumPeer.h

@ -31,6 +31,8 @@
#include <libp2p/Capability.h> #include <libp2p/Capability.h>
#include "CommonNet.h" #include "CommonNet.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -65,7 +67,7 @@ private:
void giveUpOnFetch(); void giveUpOnFetch();
uint m_protocolVersion; unsigned m_protocolVersion;
u256 m_networkId; u256 m_networkId;
h256 m_latestHash; ///< Peer's latest block's hash. h256 m_latestHash; ///< Peer's latest block's hash.
@ -83,3 +85,4 @@ private:
}; };
} }
}

7
libethereum/Executive.cpp

@ -25,7 +25,8 @@
#include "State.h" #include "State.h"
#include "ExtVM.h" #include "ExtVM.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
#define ETH_VMTRACE 1 #define ETH_VMTRACE 1
@ -157,8 +158,8 @@ OnOpFunc Executive::simpleTrace()
o << " STORAGE" << endl; o << " STORAGE" << endl;
for (auto const& i: ext.state().storage(ext.myAddress)) for (auto const& i: ext.state().storage(ext.myAddress))
o << showbase << hex << i.first << ": " << i.second << endl; o << showbase << hex << i.first << ": " << i.second << endl;
eth::LogOutputStream<VMTraceChannel, false>(true) << o.str(); dev::LogOutputStream<VMTraceChannel, false>(true) << o.str();
eth::LogOutputStream<VMTraceChannel, false>(false) << " | " << dec << ext.level << " | " << ext.myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << dec << vm.gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32" << " ]"; dev::LogOutputStream<VMTraceChannel, false>(false) << " | " << dec << ext.level << " | " << ext.myAddress << " | #" << steps << " | " << hex << setw(4) << setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << dec << vm.gas() << " | -" << dec << gasCost << " | " << newMemSize << "x32" << " ]";
}; };
} }

3
libethereum/Executive.h

@ -29,6 +29,8 @@
#include "Transaction.h" #include "Transaction.h"
#include "Manifest.h" #include "Manifest.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -78,3 +80,4 @@ private:
}; };
} }
}

4
libethereum/ExtVM.h

@ -27,6 +27,8 @@
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
#include "State.h" #include "State.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -122,5 +124,5 @@ private:
}; };
} }
}

3
libethereum/Manifest.cpp

@ -21,7 +21,8 @@
#include "Manifest.h" #include "Manifest.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
Manifest::Manifest(bytesConstRef _r) Manifest::Manifest(bytesConstRef _r)
{ {

3
libethereum/Manifest.h

@ -26,6 +26,8 @@
#include <libethential/RLP.h> #include <libethential/RLP.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -68,3 +70,4 @@ struct Manifest
}; };
} }
}

5
libethereum/MessageFilter.cpp

@ -24,7 +24,8 @@
#include <libethcore/SHA3.h> #include <libethcore/SHA3.h>
#include "State.h" #include "State.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
void MessageFilter::fillStream(RLPStream& _s) const void MessageFilter::fillStream(RLPStream& _s) const
{ {
@ -35,7 +36,7 @@ h256 MessageFilter::sha3() const
{ {
RLPStream s; RLPStream s;
fillStream(s); fillStream(s);
return eth::sha3(s.out()); return dev::eth::sha3(s.out());
} }
bool MessageFilter::matches(h256 _bloom) const bool MessageFilter::matches(h256 _bloom) const

3
libethereum/MessageFilter.h

@ -26,6 +26,8 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include "PastMessage.h" #include "PastMessage.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -71,3 +73,4 @@ private:
}; };
} }
}

3
libethereum/Miner.cpp

@ -23,7 +23,8 @@
#include "Miner.h" #include "Miner.h"
#include "State.h" #include "State.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
Miner::Miner(MinerHost* _host, unsigned _id): Miner::Miner(MinerHost* _host, unsigned _id):
m_host(_host), m_host(_host),

7
libethereum/Miner.h

@ -29,6 +29,8 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include "State.h" #include "State.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -41,8 +43,8 @@ struct MineProgress
double requirement = 0; ///< The PoW requirement - as the second logarithm of the minimum acceptable hash. double requirement = 0; ///< The PoW requirement - as the second logarithm of the minimum acceptable hash.
double best = 1e99; ///< The PoW achievement - as the second logarithm of the minimum found hash. double best = 1e99; ///< The PoW achievement - as the second logarithm of the minimum found hash.
double current = 0; ///< The most recent PoW achievement - as the second logarithm of the presently found hash. double current = 0; ///< The most recent PoW achievement - as the second logarithm of the presently found hash.
uint hashes = 0; ///< Total number of hashes computed. unsigned hashes = 0; ///< Total number of hashes computed.
uint ms = 0; ///< Total number of milliseconds of mining thus far. unsigned ms = 0; ///< Total number of milliseconds of mining thus far.
}; };
/** /**
@ -139,3 +141,4 @@ private:
}; };
} }
}

3
libethereum/PastMessage.cpp

@ -21,4 +21,5 @@
#include "PastMessage.h" #include "PastMessage.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;

3
libethereum/PastMessage.h

@ -25,6 +25,8 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include "Manifest.h" #include "Manifest.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -51,3 +53,4 @@ struct PastMessage
typedef std::vector<PastMessage> PastMessages; typedef std::vector<PastMessage> PastMessages;
} }
}

11
libethereum/State.cpp

@ -33,7 +33,8 @@
#include "Defaults.h" #include "Defaults.h"
#include "ExtVM.h" #include "ExtVM.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
#define ctrace clog(StateTrace) #define ctrace clog(StateTrace)
@ -72,7 +73,7 @@ State::State(Address _coinbaseAddress, OverlayDB const& _db):
paranoia("beginning of normal construction.", true); paranoia("beginning of normal construction.", true);
eth::commit(genesisState(), m_db, m_state); dev::eth::commit(genesisState(), m_db, m_state);
m_db.commit(); m_db.commit();
paranoia("after DB commit of normal construction.", true); paranoia("after DB commit of normal construction.", true);
@ -300,7 +301,7 @@ void State::ensureCached(std::map<Address, AddressState>& _cache, Address _a, bo
void State::commit() void State::commit()
{ {
eth::commit(m_cache, m_db, m_state); dev::eth::commit(m_cache, m_db, m_state);
m_cache.clear(); m_cache.clear();
} }
@ -761,7 +762,7 @@ void State::commitToMine(BlockChain const& _bc)
m_currentBlock.parentHash = m_previousBlock.hash; m_currentBlock.parentHash = m_previousBlock.hash;
} }
MineInfo State::mine(uint _msTimeout, bool _turbo) MineInfo State::mine(unsigned _msTimeout, bool _turbo)
{ {
// Update difficulty according to timestamp. // Update difficulty according to timestamp.
m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock); m_currentBlock.difficulty = m_currentBlock.calculateDifficulty(m_previousBlock);
@ -1200,7 +1201,7 @@ void State::applyRewards(Addresses const& _uncleAddresses)
addBalance(m_currentBlock.coinbaseAddress, r); addBalance(m_currentBlock.coinbaseAddress, r);
} }
std::ostream& eth::operator<<(std::ostream& _out, State const& _s) std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s)
{ {
_out << "--- " << _s.rootHash() << std::endl; _out << "--- " << _s.rootHash() << std::endl;
std::set<Address> d; std::set<Address> d;

6
libethereum/State.h

@ -38,6 +38,8 @@
#include "Executive.h" #include "Executive.h"
#include "AccountDiff.h" #include "AccountDiff.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -120,7 +122,7 @@ public:
/// This function is thread-safe. You can safely have other interactions with this object while it is happening. /// This function is thread-safe. You can safely have other interactions with this object while it is happening.
/// @param _msTimeout Timeout before return in milliseconds. /// @param _msTimeout Timeout before return in milliseconds.
/// @returns Information on the mining. /// @returns Information on the mining.
MineInfo mine(uint _msTimeout = 1000, bool _turbo = false); MineInfo mine(unsigned _msTimeout = 1000, bool _turbo = false);
/** Commit to DB and build the final block if the previous call to mine()'s result is completion. /** Commit to DB and build the final block if the previous call to mine()'s result is completion.
* Typically looks like: * Typically looks like:
@ -363,5 +365,5 @@ void commit(std::map<Address, AddressState> const& _cache, DB& _db, TrieDB<Addre
} }
} }
}

5
libethereum/Transaction.cpp

@ -25,7 +25,8 @@
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include "Transaction.h" #include "Transaction.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
#define ETH_ADDRESS_DEBUG 0 #define ETH_ADDRESS_DEBUG 0
@ -78,7 +79,7 @@ Address Transaction::sender() const
throw InvalidSignature(); throw InvalidSignature();
// TODO: check right160 is correct and shouldn't be left160. // TODO: check right160 is correct and shouldn't be left160.
m_sender = right160(eth::sha3(bytesConstRef(&(pubkey[1]), 64))); m_sender = right160(dev::eth::sha3(bytesConstRef(&(pubkey[1]), 64)));
#if ETH_ADDRESS_DEBUG #if ETH_ADDRESS_DEBUG
cout << "---- RECOVER -------------------------------" << endl; cout << "---- RECOVER -------------------------------" << endl;

9
libethereum/Transaction.h

@ -25,6 +25,8 @@
#include <libethcore/SHA3.h> #include <libethcore/SHA3.h>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -65,8 +67,8 @@ struct Transaction
void fillStream(RLPStream& _s, bool _sig = true) const; void fillStream(RLPStream& _s, bool _sig = true) const;
bytes rlp(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return s.out(); } bytes rlp(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return s.out(); }
std::string rlpString(bool _sig = true) const { return asString(rlp(_sig)); } std::string rlpString(bool _sig = true) const { return asString(rlp(_sig)); }
h256 sha3(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return eth::sha3(s.out()); } h256 sha3(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::eth::sha3(s.out()); }
bytes sha3Bytes(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return eth::sha3Bytes(s.out()); } bytes sha3Bytes(bool _sig = true) const { RLPStream s; fillStream(s, _sig); return dev::eth::sha3Bytes(s.out()); }
private: private:
mutable Address m_sender; mutable Address m_sender;
@ -94,5 +96,4 @@ inline std::ostream& operator<<(std::ostream& _out, Transaction const& _t)
} }
} }
}

3
libethereum/TransactionQueue.cpp

@ -25,7 +25,8 @@
#include <libethcore/Exceptions.h> #include <libethcore/Exceptions.h>
#include "Transaction.h" #include "Transaction.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bool TransactionQueue::import(bytesConstRef _transactionRLP) bool TransactionQueue::import(bytesConstRef _transactionRLP)
{ {

4
libethereum/TransactionQueue.h

@ -26,6 +26,8 @@
#include "libethcore/CommonEth.h" #include "libethcore/CommonEth.h"
#include <libethential/Guards.h> #include <libethential/Guards.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -58,5 +60,5 @@ private:
}; };
} }
}

13
libethereum/Utility.cpp

@ -24,9 +24,10 @@
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bytes eth::parseData(string const& _args) bytes dev::eth::parseData(string const& _args)
{ {
bytes m_data; bytes m_data;
@ -41,12 +42,12 @@ bytes eth::parseData(string const& _args)
{ {
u256 v((string)what[2]); u256 v((string)what[2]);
if (what[6] == "szabo") if (what[6] == "szabo")
v *= eth::szabo; v *= dev::eth::szabo;
else if (what[5] == "finney") else if (what[5] == "finney")
v *= eth::finney; v *= dev::eth::finney;
else if (what[4] == "ether") else if (what[4] == "ether")
v *= eth::ether; v *= dev::eth::ether;
bytes bs = eth::toCompactBigEndian(v); bytes bs = dev::toCompactBigEndian(v);
if (what[1] != "$") if (what[1] != "$")
for (auto i = bs.size(); i < 32; ++i) for (auto i = bs.size(); i < 32; ++i)
m_data.push_back(0); m_data.push_back(0);

3
libethereum/Utility.h

@ -24,9 +24,12 @@
#include <string> #include <string>
#include <libethential/Common.h> #include <libethential/Common.h>
namespace dev
{
namespace eth namespace eth
{ {
bytes parseData(std::string const& _args); bytes parseData(std::string const& _args);
} }
}

3
libethereumx/Ethereum.cpp

@ -24,7 +24,8 @@
#include <libethential/Log.h> #include <libethential/Log.h>
#include <libethereum/Client.h> #include <libethereum/Client.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
using namespace p2p; using namespace p2p;
Ethereum::Ethereum() Ethereum::Ethereum()

3
libethereumx/Ethereum.h

@ -36,6 +36,8 @@
#include <libethereum/MessageFilter.h> #include <libethereum/MessageFilter.h>
#include <libethereum/CommonNet.h> #include <libethereum/CommonNet.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -143,3 +145,4 @@ private:
}; };
} }
}

3
libevm/ExtVMFace.cpp

@ -22,7 +22,8 @@
#include "ExtVMFace.h" #include "ExtVMFace.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock): ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock):
myAddress(_myAddress), myAddress(_myAddress),

3
libevm/ExtVMFace.h

@ -26,6 +26,8 @@
#include <libethcore/CommonEth.h> #include <libethcore/CommonEth.h>
#include <libethcore/BlockInfo.h> #include <libethcore/BlockInfo.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -107,3 +109,4 @@ public:
}; };
} }
}

23
libevm/FeeStructure.cpp

@ -22,15 +22,16 @@
#include "FeeStructure.h" #include "FeeStructure.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
u256 const eth::c_stepGas = 1; u256 const dev::eth::c_stepGas = 1;
u256 const eth::c_balanceGas = 20; u256 const dev::eth::c_balanceGas = 20;
u256 const eth::c_sha3Gas = 20; u256 const dev::eth::c_sha3Gas = 20;
u256 const eth::c_sloadGas = 20; u256 const dev::eth::c_sloadGas = 20;
u256 const eth::c_sstoreGas = 100; u256 const dev::eth::c_sstoreGas = 100;
u256 const eth::c_createGas = 100; u256 const dev::eth::c_createGas = 100;
u256 const eth::c_callGas = 20; u256 const dev::eth::c_callGas = 20;
u256 const eth::c_memoryGas = 1; u256 const dev::eth::c_memoryGas = 1;
u256 const eth::c_txDataGas = 5; u256 const dev::eth::c_txDataGas = 5;
u256 const eth::c_txGas = 500; u256 const dev::eth::c_txGas = 500;

3
libevm/FeeStructure.h

@ -23,6 +23,8 @@
#include <libethential/Common.h> #include <libethential/Common.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -38,3 +40,4 @@ extern u256 const c_txDataGas; ///< Per byte of data attached to a transaction
extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions.
} }
}

3
libevm/VM.cpp

@ -22,7 +22,8 @@
#include "VM.h" #include "VM.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
void VM::reset(u256 _gas) void VM::reset(u256 _gas)
{ {

10
libevm/VM.h

@ -30,6 +30,8 @@
#include "FeeStructure.h" #include "FeeStructure.h"
#include "ExtVMFace.h" #include "ExtVMFace.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -87,9 +89,9 @@ private:
} }
// INLINE: // INLINE:
template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, OnOpFunc const& _onOp, uint64_t _steps) template <class Ext> dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc const& _onOp, uint64_t _steps)
{ {
auto memNeed = [](eth::u256 _offset, eth::u256 _size) { return _size ? _offset + _size : 0; }; auto memNeed = [](dev::u256 _offset, dev::u256 _size) { return _size ? _offset + _size : 0; };
u256 nextPC = m_curPC + 1; u256 nextPC = m_curPC + 1;
auto osteps = _steps; auto osteps = _steps;
@ -310,7 +312,7 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, OnOpFunc const& _
break; break;
case Instruction::BYTE: case Instruction::BYTE:
require(2); require(2);
m_stack[m_stack.size() - 2] = m_stack.back() < 32 ? (m_stack[m_stack.size() - 2] >> (uint)(8 * (31 - m_stack.back()))) & 0xff : 0; m_stack[m_stack.size() - 2] = m_stack.back() < 32 ? (m_stack[m_stack.size() - 2] >> (unsigned)(8 * (31 - m_stack.back()))) & 0xff : 0;
m_stack.pop_back(); m_stack.pop_back();
break; break;
case Instruction::ADDMOD: case Instruction::ADDMOD:
@ -688,4 +690,4 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, OnOpFunc const& _
throw StepsDone(); throw StepsDone();
return bytesConstRef(); return bytesConstRef();
} }
}

11
libevmface/Instruction.cpp

@ -23,9 +23,10 @@
#include <libethential/Common.h> #include <libethential/Common.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
const std::map<std::string, Instruction> eth::c_instructions = const std::map<std::string, Instruction> dev::eth::c_instructions =
{ {
{ "STOP", Instruction::STOP }, { "STOP", Instruction::STOP },
{ "ADD", Instruction::ADD }, { "ADD", Instruction::ADD },
@ -279,10 +280,10 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} } { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} }
}; };
string eth::disassemble(bytes const& _mem) string dev::eth::disassemble(bytes const& _mem)
{ {
stringstream ret; stringstream ret;
uint numerics = 0; unsigned numerics = 0;
for (auto it = _mem.begin(); it != _mem.end(); ++it) for (auto it = _mem.begin(); it != _mem.end(); ++it)
{ {
byte n = *it; byte n = *it;
@ -303,7 +304,7 @@ string eth::disassemble(bytes const& _mem)
return ret.str(); return ret.str();
} }
InstructionInfo eth::instructionInfo(Instruction _inst) InstructionInfo dev::eth::instructionInfo(Instruction _inst)
{ {
try try
{ {

3
libevmface/Instruction.h

@ -27,6 +27,8 @@
namespace boost { namespace spirit { class utree; } } namespace boost { namespace spirit { class utree; } }
namespace sp = boost::spirit; namespace sp = boost::spirit;
namespace dev
{
namespace eth namespace eth
{ {
@ -188,3 +190,4 @@ extern const std::map<std::string, Instruction> c_instructions;
std::string disassemble(bytes const& _mem); std::string disassemble(bytes const& _mem);
} }
}

17
liblll/Assembly.cpp

@ -24,7 +24,8 @@
#include <libethential/Log.h> #include <libethential/Log.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
int AssemblyItem::deposit() const int AssemblyItem::deposit() const
{ {
@ -59,7 +60,7 @@ unsigned Assembly::bytesRequired() const
ret += 33; ret += 33;
break; break;
case Push: case Push:
ret += 1 + max<unsigned>(1, eth::bytesRequired(i.m_data)); ret += 1 + max<unsigned>(1, dev::bytesRequired(i.m_data));
break; break;
case PushSubSize: case PushSubSize:
ret += 4; // worst case: a 16MB program ret += 4; // worst case: a 16MB program
@ -71,7 +72,7 @@ unsigned Assembly::bytesRequired() const
case Tag:; case Tag:;
default:; default:;
} }
if (eth::bytesRequired(ret) <= br) if (dev::bytesRequired(ret) <= br)
return ret; return ret;
} }
} }
@ -110,7 +111,7 @@ void Assembly::append(Assembly const& _a, int _deposit)
} }
} }
ostream& eth::operator<<(ostream& _out, AssemblyItemsConstRef _i) ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
{ {
for (AssemblyItem const& i: _i) for (AssemblyItem const& i: _i)
switch (i.type()) switch (i.type())
@ -217,7 +218,7 @@ inline bool matches(AssemblyItemsConstRef _a, AssemblyItemsConstRef _b)
} }
struct OptimiserChannel: public LogChannel { static const char* name() { return "OPT"; } static const int verbosity = 12; }; struct OptimiserChannel: public LogChannel { static const char* name() { return "OPT"; } static const int verbosity = 12; };
#define copt eth::LogOutputStream<OptimiserChannel, true>() #define copt dev::LogOutputStream<OptimiserChannel, true>()
Assembly& Assembly::optimise(bool _enable) Assembly& Assembly::optimise(bool _enable)
{ {
@ -353,7 +354,7 @@ bytes Assembly::assemble() const
vector<unsigned> tagPos(m_usedTags); vector<unsigned> tagPos(m_usedTags);
map<unsigned, unsigned> tagRef; map<unsigned, unsigned> tagRef;
multimap<h256, unsigned> dataRef; multimap<h256, unsigned> dataRef;
unsigned bytesPerTag = eth::bytesRequired(totalBytes); unsigned bytesPerTag = dev::bytesRequired(totalBytes);
byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag; byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag;
for (auto const& i: m_subs) for (auto const& i: m_subs)
@ -380,7 +381,7 @@ bytes Assembly::assemble() const
} }
case Push: case Push:
{ {
byte b = max<unsigned>(1, eth::bytesRequired(i.m_data)); byte b = max<unsigned>(1, dev::bytesRequired(i.m_data));
ret.push_back((byte)Instruction::PUSH1 - 1 + b); ret.push_back((byte)Instruction::PUSH1 - 1 + b);
ret.resize(ret.size() + b); ret.resize(ret.size() + b);
bytesRef byr(&ret.back() + 1 - b, b); bytesRef byr(&ret.back() + 1 - b, b);
@ -404,7 +405,7 @@ bytes Assembly::assemble() const
case PushSubSize: case PushSubSize:
{ {
auto s = m_data[i.m_data].size(); auto s = m_data[i.m_data].size();
byte b = max<unsigned>(1, eth::bytesRequired(s)); byte b = max<unsigned>(1, dev::bytesRequired(s));
ret.push_back((byte)Instruction::PUSH1 - 1 + b); ret.push_back((byte)Instruction::PUSH1 - 1 + b);
ret.resize(ret.size() + b); ret.resize(ret.size() + b);
bytesRef byr(&ret.back() + 1 - b, b); bytesRef byr(&ret.back() + 1 - b, b);

3
liblll/Assembly.h

@ -27,6 +27,8 @@
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include "Exceptions.h" #include "Exceptions.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -130,3 +132,4 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a)
} }
} }
}

3
liblll/CodeFragment.cpp

@ -28,7 +28,8 @@
#include "CompilerState.h" #include "CompilerState.h"
#include "Parser.h" #include "Parser.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
namespace qi = boost::spirit::qi; namespace qi = boost::spirit::qi;
namespace px = boost::phoenix; namespace px = boost::phoenix;
namespace sp = boost::spirit; namespace sp = boost::spirit;

3
liblll/CodeFragment.h

@ -29,6 +29,8 @@
namespace boost { namespace spirit { class utree; } } namespace boost { namespace spirit { class utree; } }
namespace sp = boost::spirit; namespace sp = boost::spirit;
namespace dev
{
namespace eth namespace eth
{ {
@ -58,3 +60,4 @@ private:
static const CodeFragment NullCodeFragment; static const CodeFragment NullCodeFragment;
} }
}

9
liblll/Compiler.cpp

@ -25,9 +25,10 @@
#include "CodeFragment.h" #include "CodeFragment.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bytes eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors) bytes dev::eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors)
{ {
try try
{ {
@ -52,7 +53,7 @@ bytes eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors)
return bytes(); return bytes();
} }
std::string eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector<std::string>* _errors) std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector<std::string>* _errors)
{ {
try try
{ {
@ -76,7 +77,7 @@ std::string eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector
return string(); return string();
} }
string eth::parseLLL(string const& _src) string dev::eth::parseLLL(string const& _src)
{ {
sp::utree o; sp::utree o;
try try

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save