 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
70 if (_wp.headerHash() == m_work.headerHash())
73 for (
auto const& m: m_miners)
78 void setSealers(std::map<std::string, SealerDescriptor>
const& _sealers) { m_sealers = _sealers; }
83 bool start(std::string
const& _sealer)
86 if (!m_miners.empty() && m_lastSealer == _sealer)
88 if (!m_sealers.count(_sealer))
92 auto ins = m_sealers[_sealer].instances();
93 m_miners.reserve(ins);
94 for (
unsigned i = 0; i < ins; ++i)
96 m_miners.push_back(std::shared_ptr<Miner>(m_sealers[_sealer].create(std::make_pair(
this, i))));
97 m_miners.back()->setWork(m_work);
100 m_lastSealer = _sealer;
127 p.
ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_lastStart).count();
130 for (
auto const& i: m_miners)
131 p.
hashes += i->hashCount();
144 for (
auto const& i: m_miners)
168 if (m_onSolutionFound && m_onSolutionFound(_s))
169 if (x_minerWork.try_lock())
171 for (std::shared_ptr<Miner>
const& m: m_miners)
175 x_minerWork.unlock();
184 m_lastStart = std::chrono::steady_clock::now();
188 std::vector<std::shared_ptr<Miner>> m_miners;
191 std::atomic<bool> m_isMining = {
false};
194 mutable WorkingProgress m_progress;
195 std::chrono::steady_clock::time_point m_lastStart;
199 std::map<std::string, SealerDescriptor> m_sealers;
200 std::string m_lastSealer;
boost::shared_mutex SharedMutex
Class for hosting one or more Miners.
std::function< unsigned()> instances
bool start(std::string const &_sealer)
Start a number of miners.
void resetMiningProgress()
Reset the mining progess counter.
A miner - a member and adoptee of the Farm.
Describes the progress of a mining operation.
typename PoW::WorkPackage WorkPackage
uint64_t hashes
Total number of hashes computed.
bool submitProof(Solution const &_s, Miner *_m) override
Called from a Miner to note a WorkPackage has a solution.
void setWork(WorkPackage const &_wp)
Sets the current mining mission.
void setSealers(std::map< std::string, SealerDescriptor > const &_sealers)
void onSolutionFound(SolutionFound const &_handler)
Provides a valid header based upon that received previously with setWork().
A collective of Miners. Miners ask for work, then submit proofs @threadsafe.
typename PoW::Solution Solution
boost::unique_lock< boost::shared_mutex > WriteGuard
boost::shared_lock< boost::shared_mutex > ReadGuard
std::function< Miner *(typename Miner::ConstructionInfo ci)> create
std::pair< FarmFace *, unsigned > ConstructionInfo
#define DEV_READ_GUARDED(MUTEX)
std::function< bool(Solution const &)> SolutionFound
uint64_t ms
Total number of milliseconds of mining thus far.
WorkingProgress const & miningProgress() const
Get information on the progress of mining this work package.
void stop()
Stop all mining activities.