Files
thehub/libs/server/miner.h
T
tomFlowee 639a57d957 [Refactor] primitives/BlockHeader -> BlockHeaderFields
This avoids a naming conflict with a p2p class BlockHeader.

Notice that the block data structures are mostly still private API, they
are in the utils dir but headers are not installed, nobody has needed
them so far.
2021-11-02 11:05:14 +01:00

86 lines
2.6 KiB
C++

/*
* This file is part of the Flowee project
* Copyright (C) 2009-2010 Satoshi Nakamoto
* Copyright (C) 2009-2015 The Bitcoin Core developers
* Copyright (C) 2016-2021 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOWEE_MINER_H
#define FLOWEE_MINER_H
#include "primitives/MutableBlock.h"
#include <mutex>
#include <boost/thread.hpp>
class CBlockIndex;
namespace Validation { class Engine; }
class CChainParams;
class CReserveKey;
class CScript;
class CWallet;
namespace Consensus { struct Params; }
struct CBlockTemplate
{
MutableBlock block;
std::vector<int64_t> vTxFees;
};
class Mining
{
public:
/**
* parse /a the public address and return a script used to make it
* a coinbase.
* @throws runtime_error when the input is not usable
*/
static CScript ScriptForCoinbase(const std::string &publicAddress);
/** Run the miner threads */
static void GenerateBitcoins(bool fGenerate, int nThreads, const CChainParams& chainparams, const std::string &GetCoinbase);
static void Stop();
static Mining *instance();
Mining();
~Mining();
/**
* Generate a new block, without valid proof-of-work, using the global settings
*/
CBlockTemplate* CreateNewBlock() const;
/** Generate a new block, without valid proof-of-work */
CBlockTemplate* CreateNewBlock(Validation::Engine &validationEngine) const;
/** Modify the extranonce in a block */
void IncrementExtraNonce(MutableBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
static int64_t UpdateTime(BlockHeaderFields* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
CScript GetCoinbase() const;
void SetCoinbase(const CScript &coinbase);
private:
boost::thread_group* m_minerThreads;
static Mining *s_instance;
mutable std::mutex m_lock;
CScript m_coinbase;
std::vector<unsigned char> m_coinbaseComment;
uint256 m_hashPrevBlock;
};
#endif