TransactionReceipt.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file TransactionReceipt.h
  15. * @author Gav Wood <i@gavwood.com>
  16. * @date 2014
  17. */
  18. #pragma once
  19. #include <array>
  20. #include <libdevcore/Common.h>
  21. #include <libdevcore/RLP.h>
  22. #include <libevm/ExtVMFace.h>
  23. namespace dev
  24. {
  25. namespace eth
  26. {
  27. class TransactionReceipt
  28. {
  29. public:
  30. TransactionReceipt(bytesConstRef _rlp);
  31. TransactionReceipt(h256 _root, u256 _gasUsed, LogEntries const& _log);
  32. h256 const& stateRoot() const { return m_stateRoot; }
  33. u256 const& gasUsed() const { return m_gasUsed; }
  34. LogBloom const& bloom() const { return m_bloom; }
  35. LogEntries const& log() const { return m_log; }
  36. void streamRLP(RLPStream& _s) const;
  37. bytes rlp() const { RLPStream s; streamRLP(s); return s.out(); }
  38. private:
  39. h256 m_stateRoot;
  40. u256 m_gasUsed;
  41. LogBloom m_bloom;
  42. LogEntries m_log;
  43. };
  44. using TransactionReceipts = std::vector<TransactionReceipt>;
  45. std::ostream& operator<<(std::ostream& _out, eth::TransactionReceipt const& _r);
  46. class LocalisedTransactionReceipt: public TransactionReceipt
  47. {
  48. public:
  49. LocalisedTransactionReceipt(
  50. TransactionReceipt const& _t,
  51. h256 const& _hash,
  52. h256 const& _blockHash,
  53. BlockNumber _blockNumber,
  54. unsigned _transactionIndex,
  55. Address const& _contractAddress = Address()
  56. ):
  57. TransactionReceipt(_t),
  58. m_hash(_hash),
  59. m_blockHash(_blockHash),
  60. m_blockNumber(_blockNumber),
  61. m_transactionIndex(_transactionIndex),
  62. m_contractAddress(_contractAddress)
  63. {
  64. LogEntries entries = log();
  65. for (unsigned i = 0; i < entries.size(); i++)
  66. m_localisedLogs.push_back(LocalisedLogEntry(
  67. entries[i],
  68. m_blockHash,
  69. m_blockNumber,
  70. m_hash,
  71. m_transactionIndex,
  72. i
  73. ));
  74. }
  75. h256 const& hash() const { return m_hash; }
  76. h256 const& blockHash() const { return m_blockHash; }
  77. BlockNumber blockNumber() const { return m_blockNumber; }
  78. unsigned transactionIndex() const { return m_transactionIndex; }
  79. Address const& contractAddress() const { return m_contractAddress; }
  80. LocalisedLogEntries const& localisedLogs() const { return m_localisedLogs; };
  81. private:
  82. h256 m_hash;
  83. h256 m_blockHash;
  84. BlockNumber m_blockNumber;
  85. unsigned m_transactionIndex = 0;
  86. Address m_contractAddress;
  87. LocalisedLogEntries m_localisedLogs;
  88. };
  89. }
  90. }