CPUMiner.h 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (C) 1883 Thomas Edison - All Rights Reserved
  2. * You may use, distribute and modify this code under the
  3. * terms of the GPLv3 license, which unfortunately won't be
  4. * written for another century.
  5. *
  6. * You should have received a copy of the LICENSE file with
  7. * this file.
  8. */
  9. #pragma once
  10. #include <libdev/Worker.h>
  11. #include <libeth/EthashAux.h>
  12. #include <libeth/Miner.h>
  13. #include <functional>
  14. namespace dev {
  15. namespace eth {
  16. class CPUMiner : public Miner {
  17. public:
  18. CPUMiner(unsigned _index, DeviceDescriptor& _device);
  19. ~CPUMiner() override;
  20. static unsigned getNumDevices();
  21. static void enumDevices(std::map<string, DeviceDescriptor>& _DevicesCollection);
  22. void search(const dev::eth::WorkPackage& w);
  23. protected:
  24. bool initDevice() override;
  25. bool initEpoch() override;
  26. void kick_miner() override;
  27. private:
  28. atomic<bool> m_new_work = {false};
  29. void workLoop() override;
  30. };
  31. } // namespace eth
  32. } // namespace dev