Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
dev::eth::GenericFarm< PoW > Class Template Reference

A collective of Miners. More...

#include <GenericFarm.h>

Inheritance diagram for dev::eth::GenericFarm< PoW >:
[legend]
Collaboration diagram for dev::eth::GenericFarm< PoW >:
[legend]

Classes

struct  SealerDescriptor
 

Public Types

using WorkPackage = typename PoW::WorkPackage
 
using Solution = typename PoW::Solution
 
using Miner = GenericMiner< PoW >
 
using SolutionFound = std::function< bool(Solution const &)>
 
- Public Types inherited from dev::eth::GenericFarmFace< PoW >
using WorkPackage = typename PoW::WorkPackage
 
using Solution = typename PoW::Solution
 
using Miner = GenericMiner< PoW >
 

Public Member Functions

 ~GenericFarm ()
 
void setWork (WorkPackage const &_wp)
 Sets the current mining mission. More...
 
void setSealers (std::map< std::string, SealerDescriptor > const &_sealers)
 
bool start (std::string const &_sealer)
 Start a number of miners. More...
 
void stop ()
 Stop all mining activities. More...
 
bool isMining () const
 
WorkingProgress const & miningProgress () const
 Get information on the progress of mining this work package. More...
 
void resetMiningProgress ()
 Reset the mining progess counter. More...
 
void onSolutionFound (SolutionFound const &_handler)
 Provides a valid header based upon that received previously with setWork(). More...
 
WorkPackage work () const
 
bool submitProof (Solution const &_s, Miner *_m) override
 Called from a Miner to note a WorkPackage has a solution. More...
 
- Public Member Functions inherited from dev::eth::GenericFarmFace< PoW >
virtual ~GenericFarmFace ()
 

Private Member Functions

void resetTimer ()
 

Private Attributes

SharedMutex x_minerWork
 
std::vector< std::shared_ptr< Miner > > m_miners
 
WorkPackage m_work
 
std::atomic< bool > m_isMining = {false}
 
SharedMutex x_progress
 
WorkingProgress m_progress
 
std::chrono::steady_clock::time_point m_lastStart
 
SolutionFound m_onSolutionFound
 
std::map< std::string, SealerDescriptorm_sealers
 
std::string m_lastSealer
 

Detailed Description

template<class PoW>
class dev::eth::GenericFarm< PoW >

A collective of Miners.

Miners ask for work, then submit proofs

Definition at line 45 of file GenericFarm.h.

Member Typedef Documentation

template<class PoW>
using dev::eth::GenericFarm< PoW >::Miner = GenericMiner<PoW>

Definition at line 50 of file GenericFarm.h.

template<class PoW>
using dev::eth::GenericFarm< PoW >::Solution = typename PoW::Solution

Definition at line 49 of file GenericFarm.h.

template<class PoW>
using dev::eth::GenericFarm< PoW >::SolutionFound = std::function<bool(Solution const&)>

Definition at line 149 of file GenericFarm.h.

template<class PoW>
using dev::eth::GenericFarm< PoW >::WorkPackage = typename PoW::WorkPackage

Definition at line 48 of file GenericFarm.h.

Constructor & Destructor Documentation

template<class PoW>
dev::eth::GenericFarm< PoW >::~GenericFarm ( )
inline

Definition at line 58 of file GenericFarm.h.

Member Function Documentation

template<class PoW>
bool dev::eth::GenericFarm< PoW >::isMining ( ) const
inline

Definition at line 115 of file GenericFarm.h.

template<class PoW>
WorkingProgress const& dev::eth::GenericFarm< PoW >::miningProgress ( ) const
inline

Get information on the progress of mining this work package.

Returns
The progress with mining so far.

Definition at line 124 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::onSolutionFound ( SolutionFound const &  _handler)
inline

Provides a valid header based upon that received previously with setWork().

Parameters
_biThe now-valid header.
Returns
true if the header was good and that the Farm should pause until more work is submitted.

Definition at line 156 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::resetMiningProgress ( )
inline

Reset the mining progess counter.

Definition at line 141 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::resetTimer ( )
inlineprivate

Definition at line 182 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::setSealers ( std::map< std::string, SealerDescriptor > const &  _sealers)
inline

Definition at line 78 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::setWork ( WorkPackage const &  _wp)
inline

Sets the current mining mission.

Parameters
_wpThe work package we wish to be mining.

Definition at line 67 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
bool dev::eth::GenericFarm< PoW >::start ( std::string const &  _sealer)
inline

Start a number of miners.

Definition at line 83 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
void dev::eth::GenericFarm< PoW >::stop ( )
inline

Stop all mining activities.

Definition at line 107 of file GenericFarm.h.

Here is the caller graph for this function:

template<class PoW>
bool dev::eth::GenericFarm< PoW >::submitProof ( Solution const &  _s,
Miner _m 
)
inlineoverridevirtual

Called from a Miner to note a WorkPackage has a solution.

Parameters
_pThe solution.
_wpThe WorkPackage that the Solution is for.
Returns
true iff the solution was good (implying that mining should be .

Implements dev::eth::GenericFarmFace< PoW >.

Definition at line 166 of file GenericFarm.h.

template<class PoW>
WorkPackage dev::eth::GenericFarm< PoW >::work ( ) const
inline

Definition at line 158 of file GenericFarm.h.

Member Data Documentation

template<class PoW>
std::atomic<bool> dev::eth::GenericFarm< PoW >::m_isMining = {false}
private

Definition at line 191 of file GenericFarm.h.

template<class PoW>
std::string dev::eth::GenericFarm< PoW >::m_lastSealer
private

Definition at line 200 of file GenericFarm.h.

template<class PoW>
std::chrono::steady_clock::time_point dev::eth::GenericFarm< PoW >::m_lastStart
private

Definition at line 195 of file GenericFarm.h.

template<class PoW>
std::vector<std::shared_ptr<Miner> > dev::eth::GenericFarm< PoW >::m_miners
private

Definition at line 188 of file GenericFarm.h.

template<class PoW>
SolutionFound dev::eth::GenericFarm< PoW >::m_onSolutionFound
private

Definition at line 197 of file GenericFarm.h.

template<class PoW>
WorkingProgress dev::eth::GenericFarm< PoW >::m_progress
mutableprivate

Definition at line 194 of file GenericFarm.h.

template<class PoW>
std::map<std::string, SealerDescriptor> dev::eth::GenericFarm< PoW >::m_sealers
private

Definition at line 199 of file GenericFarm.h.

template<class PoW>
WorkPackage dev::eth::GenericFarm< PoW >::m_work
private

Definition at line 189 of file GenericFarm.h.

template<class PoW>
SharedMutex dev::eth::GenericFarm< PoW >::x_minerWork
mutableprivate

Definition at line 187 of file GenericFarm.h.

template<class PoW>
SharedMutex dev::eth::GenericFarm< PoW >::x_progress
mutableprivate

Definition at line 193 of file GenericFarm.h.


The documentation for this class was generated from the following file: