Fabcoin Core  0.16.2
P2P Digital Currency
TransactionReceipt.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #include "TransactionReceipt.h"
23 
24 using namespace std;
25 using namespace dev;
26 using namespace dev::eth;
27 
28 TransactionReceipt::TransactionReceipt(bytesConstRef _rlp)
29 {
30  RLP r(_rlp);
31  m_stateRoot = (h256)r[0];
32  m_gasUsed = (u256)r[1];
33  m_bloom = (LogBloom)r[2];
34  for (auto const& i: r[3])
35  m_log.emplace_back(i);
36 }
37 
38 TransactionReceipt::TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log):
39  m_stateRoot(_root),
40  m_gasUsed(_gasUsed),
41  m_bloom(eth::bloom(_log)),
42  m_log(_log)
43 {}
44 
46 {
47  _s.appendList(4) << m_stateRoot << m_gasUsed << m_bloom;
48  _s.appendList(m_log.size());
49  for (LogEntry const& l: m_log)
50  l.streamRLP(_s);
51 }
52 
53 std::ostream& dev::eth::operator<<(std::ostream& _out, TransactionReceipt const& _r)
54 {
55  _out << "Root: " << _r.stateRoot() << std::endl;
56  _out << "Gas used: " << _r.gasUsed() << std::endl;
57  _out << "Logs: " << _r.log().size() << " entries:" << std::endl;
58  for (LogEntry const& i: _r.log())
59  {
60  _out << "Address " << i.address << ". Topics:" << std::endl;
61  for (auto const& j: i.topics)
62  _out << " " << j << std::endl;
63  _out << " Data: " << toHex(i.data) << std::endl;
64  }
65  _out << "Bloom: " << _r.bloom() << std::endl;
66  return _out;
67 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
Definition: CommonData.h:54
LogBloom const & bloom() const
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
Definition: BlockHeader.h:194
h256 const & stateRoot() const
std::hash for asio::adress
Definition: Common.h:323
u256 const & gasUsed() const
RLPStream & appendList(size_t _items)
Appends a list.
Definition: RLP.cpp:276
FixedHash< 32 > h256
Definition: FixedHash.h:340
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
void streamRLP(RLPStream &_s) const
h2048 LogBloom
The log bloom&#39;s size (2048-bit).
Definition: Common.h:58
Class for writing to an RLP bytestream.
Definition: RLP.h:383
Class for interpreting Recursive Linear-Prefix Data.
Definition: RLP.h:64
std::vector< LogEntry > LogEntries
Definition: ExtVMFace.h:110
LogBloom bloom(LogEntries const &_logs)
Definition: ExtVMFace.h:158
LogEntries const & log() const
Definition: ExtVMFace.h:88