Fabcoin Core  0.16.2
P2P Digital Currency
TransactionReceipt.h
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 #pragma once
23 
24 #include <array>
25 #include <libdevcore/Common.h>
26 #include <libdevcore/RLP.h>
27 #include <libevm/ExtVMFace.h>
28 
29 namespace dev
30 {
31 
32 namespace eth
33 {
34 
36 {
37 public:
39  TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log);
40 
41  h256 const& stateRoot() const { return m_stateRoot; }
42  u256 const& gasUsed() const { return m_gasUsed; }
43  LogBloom const& bloom() const { return m_bloom; }
44  LogEntries const& log() const { return m_log; }
45 
46  void streamRLP(RLPStream& _s) const;
47 
48  bytes rlp() const { RLPStream s; streamRLP(s); return s.out(); }
49 
50 private:
55 };
56 
57 using TransactionReceipts = std::vector<TransactionReceipt>;
58 
59 std::ostream& operator<<(std::ostream& _out, eth::TransactionReceipt const& _r);
60 
62 {
63 public:
65  TransactionReceipt const& _t,
66  h256 const& _hash,
67  h256 const& _blockHash,
68  BlockNumber _blockNumber,
69  unsigned _transactionIndex,
70  Address const& _contractAddress = Address()
71  ):
73  m_hash(_hash),
74  m_blockHash(_blockHash),
75  m_blockNumber(_blockNumber),
76  m_transactionIndex(_transactionIndex),
77  m_contractAddress(_contractAddress)
78  {
79  LogEntries entries = log();
80  for (unsigned i = 0; i < entries.size(); i++)
81  m_localisedLogs.push_back(LocalisedLogEntry(
82  entries[i],
83  m_blockHash,
84  m_blockNumber,
85  m_hash,
86  m_transactionIndex,
87  i
88  ));
89  }
90 
91  h256 const& hash() const { return m_hash; }
92  h256 const& blockHash() const { return m_blockHash; }
93  BlockNumber blockNumber() const { return m_blockNumber; }
94  unsigned transactionIndex() const { return m_transactionIndex; }
95  Address const& contractAddress() const { return m_contractAddress; }
96  LocalisedLogEntries const& localisedLogs() const { return m_localisedLogs; };
97 
98 private:
99  h256 m_hash;
102  unsigned m_transactionIndex = 0;
105 };
106 
107 }
108 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
LocalisedTransactionReceipt(TransactionReceipt const &_t, h256 const &_hash, h256 const &_blockHash, BlockNumber _blockNumber, unsigned _transactionIndex, Address const &_contractAddress=Address())
LogBloom const & bloom() const
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
Definition: BlockHeader.h:194
bytes const & out() const
Read the byte stream.
Definition: RLP.h:433
h160 Address
An Ethereum address: 20 bytes.
Definition: Common.h:62
h256 const & stateRoot() const
unsigned BlockNumber
Definition: Common.h:72
u256 const & gasUsed() const
std::vector< LocalisedLogEntry > LocalisedLogEntries
Definition: ExtVMFace.h:156
std::vector< TransactionReceipt > TransactionReceipts
Address const & contractAddress() const
std::vector< byte > bytes
Definition: Common.h:75
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
Definition: ExtVMFace.h:112
Class for writing to an RLP bytestream.
Definition: RLP.h:383
std::vector< LogEntry > LogEntries
Definition: ExtVMFace.h:110
TransactionReceipt(bytesConstRef _rlp)
LogEntries const & log() const