diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 0e36c7737..fa489ffeb 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1500,58 +1501,6 @@ void Main::on_destination_currentTextChanged() // updateFee(); } -static bytes dataFromText(QString _s) -{ - bytes ret; - while (_s.size()) - { - QRegExp r("(@|\\$)?\"([^\"]*)\"(\\s.*)?"); - QRegExp d("(@|\\$)?([0-9]+)(\\s*(ether)|(finney)|(szabo))?(\\s.*)?"); - QRegExp h("(@|\\$)?(0x)?(([a-fA-F0-9])+)(\\s.*)?"); - if (r.exactMatch(_s)) - { - for (auto i: r.cap(2)) - ret.push_back((byte)i.toLatin1()); - if (r.cap(1) != "$") - for (int i = r.cap(2).size(); i < 32; ++i) - ret.push_back(0); - else - ret.push_back(0); - _s = r.cap(3); - } - else if (d.exactMatch(_s)) - { - u256 v(d.cap(2).toStdString()); - if (d.cap(6) == "szabo") - v *= dev::eth::szabo; - else if (d.cap(5) == "finney") - v *= dev::eth::finney; - else if (d.cap(4) == "ether") - v *= dev::eth::ether; - bytes bs = dev::toCompactBigEndian(v); - if (d.cap(1) != "$") - for (auto i = bs.size(); i < 32; ++i) - ret.push_back(0); - for (auto b: bs) - ret.push_back(b); - _s = d.cap(7); - } - else if (h.exactMatch(_s)) - { - bytes bs = fromHex((((h.cap(3).size() & 1) ? "0" : "") + h.cap(3)).toStdString()); - if (h.cap(1) != "$") - for (auto i = bs.size(); i < 32; ++i) - ret.push_back(0); - for (auto b: bs) - ret.push_back(b); - _s = h.cap(5); - } - else - _s = _s.mid(1); - } - return ret; -} - static shh::Topic topicFromText(QString _s) { shh::BuildTopic ret; @@ -1679,7 +1628,7 @@ void Main::on_data_textChanged() } else { - m_data = dataFromText(ui->data->toPlainText()); + m_data = parseData(ui->data->toPlainText().toStdString()); ui->code->setHtml(QString::fromStdString(dev::memDump(m_data, 8, true))); if (ethereum()->codeAt(fromString(ui->destination->currentText()), 0).size()) { @@ -2207,7 +2156,7 @@ void Main::on_post_clicked() { shh::Message m; m.setTo(stringToPublic(ui->shhTo->currentText())); - m.setPayload(dataFromText(ui->shhData->toPlainText())); + m.setPayload(parseData(ui->shhData->toPlainText().toStdString())); Public f = stringToPublic(ui->shhFrom->currentText()); Secret from; if (m_server->ids().count(f)) diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index fffc5843f..f2d632cd4 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -44,7 +44,6 @@ class Main; namespace dev { namespace eth { class Client; class State; -class MessageFilter; }} class QQuickView; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 2fd0d3048..bbfd48e56 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -28,7 +28,6 @@ #include #include -#include "Manifest.h" #include "TransactionReceipt.h" namespace ldb = leveldb; diff --git a/libethereum/Client.h b/libethereum/Client.h index 283251e24..e8c460093 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -36,8 +36,7 @@ #include "TransactionQueue.h" #include "State.h" #include "CommonNet.h" -#include "PastMessage.h" -#include "MessageFilter.h" +#include "LogFilter.h" #include "Miner.h" #include "Interface.h" @@ -79,8 +78,6 @@ static const int GenesisBlock = INT_MIN; struct InstalledFilter { -// InstalledFilter(MessageFilter const& _f): filter(_f) {} -// MessageFilter filter; InstalledFilter(LogFilter const& _f): filter(_f) {} LogFilter filter; diff --git a/libethereum/Interface.h b/libethereum/Interface.h index d598e1f9b..28ac26819 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -26,7 +26,7 @@ #include #include #include -#include "MessageFilter.h" +#include "LogFilter.h" #include "Transaction.h" #include "AccountDiff.h" #include "BlockDetails.h" @@ -84,11 +84,6 @@ public: virtual bytes codeAt(Address _a, int _block) const = 0; virtual std::map storageAt(Address _a, int _block) const = 0; -// // [MESSAGE API] -// -// virtual PastMessages messages(unsigned _watchId) const = 0; -// virtual PastMessages messages(MessageFilter const& _filter) const = 0; - // [LOGS API] virtual LogEntries logs(unsigned _watchId) const = 0; diff --git a/libethereum/MessageFilter.cpp b/libethereum/LogFilter.cpp similarity index 97% rename from libethereum/MessageFilter.cpp rename to libethereum/LogFilter.cpp index f44587620..81cb439ba 100644 --- a/libethereum/MessageFilter.cpp +++ b/libethereum/LogFilter.cpp @@ -14,12 +14,12 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file MessageFilter.cpp +/** @file LogFilter.cpp * @author Gav Wood * @date 2014 */ -#include "MessageFilter.h" +#include "LogFilter.h" #include #include "State.h" diff --git a/libethereum/MessageFilter.h b/libethereum/LogFilter.h similarity index 98% rename from libethereum/MessageFilter.h rename to libethereum/LogFilter.h index e2c26d214..bda8e46a2 100644 --- a/libethereum/MessageFilter.h +++ b/libethereum/LogFilter.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file MessageFilter.h +/** @file LogFilter.h * @author Gav Wood * @date 2014 */ diff --git a/libethereum/Manifest.cpp b/libethereum/Manifest.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/libethereum/Manifest.h b/libethereum/Manifest.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/libethereum/PastMessage.cpp b/libethereum/PastMessage.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/libethereum/PastMessage.h b/libethereum/PastMessage.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/libethereum/TransactionReceipt.cpp b/libethereum/TransactionReceipt.cpp new file mode 100644 index 000000000..0fb104490 --- /dev/null +++ b/libethereum/TransactionReceipt.cpp @@ -0,0 +1,51 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file TransactionReceipt.cpp + * @author Gav Wood + * @date 2014 + */ + +#include "TransactionReceipt.h" + +using namespace std; +using namespace dev; +using namespace dev::eth; + +TransactionReceipt::TransactionReceipt(bytesConstRef _rlp) +{ + RLP r(_rlp); + m_stateRoot = (h256)r[0]; + m_gasUsed = (u256)r[1]; + m_bloom = (LogBloom)r[2]; + for (auto const& i: r[3]) + m_log.emplace_back(i); +} + +TransactionReceipt::TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log): + m_stateRoot(_root), + m_gasUsed(_gasUsed), + m_bloom(eth::bloom(_log)), + m_log(_log) +{} + +void TransactionReceipt::streamRLP(RLPStream& _s) const +{ + _s.appendList(4) << m_stateRoot << m_gasUsed << m_bloom; + _s.appendList(m_log.size()); + for (LogEntry const& l: m_log) + l.streamRLP(_s); +} diff --git a/libethereum/TransactionReceipt.h b/libethereum/TransactionReceipt.h index b990459d9..23995c75a 100644 --- a/libethereum/TransactionReceipt.h +++ b/libethereum/TransactionReceipt.h @@ -26,7 +26,6 @@ #include #include #include -#include "Manifest.h" namespace dev { @@ -37,21 +36,15 @@ namespace eth class TransactionReceipt { public: - TransactionReceipt(bytesConstRef _rlp) { RLP r(_rlp); m_stateRoot = (h256)r[0]; m_gasUsed = (u256)r[1]; m_bloom = (LogBloom)r[2]; for (auto const& i: r[3]) m_log.emplace_back(i); } - TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log): m_stateRoot(_root), m_gasUsed(_gasUsed), m_bloom(eth::bloom(_log)), m_log(_log) {} + TransactionReceipt(bytesConstRef _rlp); + TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log); h256 const& stateRoot() const { return m_stateRoot; } u256 const& gasUsed() const { return m_gasUsed; } LogBloom const& bloom() const { return m_bloom; } LogEntries const& log() const { return m_log; } - void streamRLP(RLPStream& _s) const - { - _s.appendList(4) << m_stateRoot << m_gasUsed << m_bloom; - _s.appendList(m_log.size()); - for (LogEntry const& l: m_log) - l.streamRLP(_s); - } + void streamRLP(RLPStream& _s) const; bytes rlp() const { RLPStream s; streamRLP(s); return s.out(); }