VerifiedBlock.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 VerfiedBlock.h
  15. * @author Gav Wood <i@gavwood.com>
  16. * @date 2014
  17. */
  18. #include <libdevcore/Common.h>
  19. #include <libethcore/BlockHeader.h>
  20. #pragma once
  21. namespace dev
  22. {
  23. namespace eth
  24. {
  25. class Transaction;
  26. /// @brief Verified block info, does not hold block data, but a reference instead
  27. struct VerifiedBlockRef
  28. {
  29. bytesConstRef block; ///< Block data reference
  30. BlockHeader info; ///< Prepopulated block info
  31. std::vector<Transaction> transactions; ///< Verified list of block transactions
  32. };
  33. /// @brief Verified block info, combines block data and verified info/transactions
  34. struct VerifiedBlock
  35. {
  36. VerifiedBlock() {}
  37. VerifiedBlock(BlockHeader&& _bi)
  38. {
  39. verified.info = std::move(_bi);
  40. }
  41. VerifiedBlock(VerifiedBlock&& _other):
  42. verified(std::move(_other.verified)),
  43. blockData(std::move(_other.blockData))
  44. {
  45. }
  46. VerifiedBlock& operator=(VerifiedBlock&& _other)
  47. {
  48. assert(&_other != this);
  49. verified = (std::move(_other.verified));
  50. blockData = (std::move(_other.blockData));
  51. return *this;
  52. }
  53. VerifiedBlockRef verified; ///< Verified block structures
  54. bytes blockData; ///< Block data
  55. private:
  56. VerifiedBlock(VerifiedBlock const&) = delete;
  57. VerifiedBlock operator=(VerifiedBlock const&) = delete;
  58. };
  59. using VerifiedBlocks = std::vector<VerifiedBlock>;
  60. }
  61. }