EthashProofOfWork.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 EthashProofOfWork.h
  15. * @author Gav Wood <i@gavwood.com>
  16. * @date 2015
  17. *
  18. * Determines the PoW algorithm.
  19. */
  20. #pragma once
  21. #include <libethcore/BlockHeader.h>
  22. namespace dev
  23. {
  24. namespace eth
  25. {
  26. /// Proof of work definition for Ethash.
  27. struct EthashProofOfWork
  28. {
  29. struct Solution
  30. {
  31. Nonce nonce;
  32. h256 mixHash;
  33. };
  34. struct Result
  35. {
  36. h256 value;
  37. h256 mixHash;
  38. };
  39. struct WorkPackage
  40. {
  41. WorkPackage() = default;
  42. WorkPackage(BlockHeader const& _bh);
  43. void reset() { headerHash = h256(); }
  44. operator bool() const { return headerHash != h256(); }
  45. h256 boundary;
  46. h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
  47. h256 seedHash;
  48. };
  49. static const WorkPackage NullWorkPackage;
  50. /// Default value of the local work size. Also known as workgroup size.
  51. static const unsigned defaultLocalWorkSize;
  52. /// Default value of the global work size as a multiplier of the local work size
  53. static const unsigned defaultGlobalWorkSizeMultiplier;
  54. /// Default value of the milliseconds per global work size (per batch)
  55. static const unsigned defaultMSPerBatch;
  56. };
  57. }
  58. }