1600086ede
The new UnspentOutputDatabase classes are only very loosly a database, we purely register and store unspent outputs there. But unline a DB we don't allow modification (just insert and delete). This replaces the coin-db (which was based on leveldb) and as first goal this gives us a higher level of stability. The level-database was known to give corruption issues. Notice that users will need to do a manual reindex on first update.
87 lines
2.6 KiB
C++
87 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 Tom Zander <tomz@freedommail.ch>
|
|
*
|
|
* 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/block.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
|
|
{
|
|
CBlock block;
|
|
std::vector<CAmount> vTxFees;
|
|
std::vector<uint32_t> vTxSigOps;
|
|
};
|
|
|
|
|
|
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(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
|
|
static int64_t UpdateTime(CBlockHeader* 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
|