Browse Source

Merge remote-tracking branch 'upstream/develop' into newTests

cl-refactor
CJentzsch 10 years ago
parent
commit
f404e968e0
  1. 57
      alethzero/MainWin.cpp
  2. 1
      alethzero/MainWin.h
  3. 1
      libethereum/BlockDetails.h
  4. 5
      libethereum/Client.h
  5. 7
      libethereum/Interface.h
  6. 4
      libethereum/LogFilter.cpp
  7. 2
      libethereum/LogFilter.h
  8. 0
      libethereum/Manifest.cpp
  9. 0
      libethereum/Manifest.h
  10. 0
      libethereum/PastMessage.cpp
  11. 0
      libethereum/PastMessage.h
  12. 51
      libethereum/TransactionReceipt.cpp
  13. 13
      libethereum/TransactionReceipt.h

57
alethzero/MainWin.cpp

@ -43,6 +43,7 @@
#include <libethereum/BlockChain.h>
#include <libethereum/ExtVM.h>
#include <libethereum/Client.h>
#include <libethereum/Utility.h>
#include <libethereum/EthereumHost.h>
#include <libethereum/DownloadMan.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
@ -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))

1
alethzero/MainWin.h

@ -44,7 +44,6 @@ class Main;
namespace dev { namespace eth {
class Client;
class State;
class MessageFilter;
}}
class QQuickView;

1
libethereum/BlockDetails.h

@ -28,7 +28,6 @@
#include <libdevcore/Log.h>
#include <libdevcore/RLP.h>
#include "Manifest.h"
#include "TransactionReceipt.h"
namespace ldb = leveldb;

5
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;

7
libethereum/Interface.h

@ -26,7 +26,7 @@
#include <libdevcore/Guards.h>
#include <libdevcrypto/Common.h>
#include <libevm/FeeStructure.h>
#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<u256, u256> 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;

4
libethereum/MessageFilter.cpp → 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 <http://www.gnu.org/licenses/>.
*/
/** @file MessageFilter.cpp
/** @file LogFilter.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "MessageFilter.h"
#include "LogFilter.h"
#include <libdevcrypto/SHA3.h>
#include "State.h"

2
libethereum/MessageFilter.h → 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 <http://www.gnu.org/licenses/>.
*/
/** @file MessageFilter.h
/** @file LogFilter.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/

0
libethereum/Manifest.cpp

0
libethereum/Manifest.h

0
libethereum/PastMessage.cpp

0
libethereum/PastMessage.h

51
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 <http://www.gnu.org/licenses/>.
*/
/** @file TransactionReceipt.cpp
* @author Gav Wood <i@gavwood.com>
* @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);
}

13
libethereum/TransactionReceipt.h

@ -26,7 +26,6 @@
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libevm/ExtVMFace.h>
#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(); }

Loading…
Cancel
Save