Correct #ifdef nesting of miner headers and helper functions
This commit is contained in:
@@ -387,30 +387,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
return pblocktemplate.release();
|
return pblocktemplate.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
|
||||||
{
|
|
||||||
// Update nExtraNonce
|
|
||||||
static uint256 hashPrevBlock;
|
|
||||||
if (hashPrevBlock != pblock->hashPrevBlock)
|
|
||||||
{
|
|
||||||
nExtraNonce = 0;
|
|
||||||
hashPrevBlock = pblock->hashPrevBlock;
|
|
||||||
}
|
|
||||||
++nExtraNonce;
|
|
||||||
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
|
|
||||||
CMutableTransaction txCoinbase(pblock->vtx[0]);
|
|
||||||
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
|
|
||||||
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
|
|
||||||
|
|
||||||
pblock->vtx[0] = txCoinbase;
|
|
||||||
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Internal miner
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey)
|
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey)
|
||||||
#else
|
#else
|
||||||
@@ -453,7 +429,32 @@ CBlockTemplate* CreateNewBlockWithKey()
|
|||||||
return CreateNewBlock(*scriptPubKey);
|
return CreateNewBlock(*scriptPubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Internal miner
|
||||||
|
//
|
||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
|
|
||||||
|
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
||||||
|
{
|
||||||
|
// Update nExtraNonce
|
||||||
|
static uint256 hashPrevBlock;
|
||||||
|
if (hashPrevBlock != pblock->hashPrevBlock)
|
||||||
|
{
|
||||||
|
nExtraNonce = 0;
|
||||||
|
hashPrevBlock = pblock->hashPrevBlock;
|
||||||
|
}
|
||||||
|
++nExtraNonce;
|
||||||
|
unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
|
||||||
|
CMutableTransaction txCoinbase(pblock->vtx[0]);
|
||||||
|
txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
|
||||||
|
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
|
||||||
|
|
||||||
|
pblock->vtx[0] = txCoinbase;
|
||||||
|
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||||
#else
|
#else
|
||||||
|
|||||||
18
src/miner.h
18
src/miner.h
@@ -26,14 +26,6 @@ struct CBlockTemplate
|
|||||||
std::vector<int64_t> vTxSigOps;
|
std::vector<int64_t> vTxSigOps;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_MINING
|
|
||||||
/** Run the miner threads */
|
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
|
|
||||||
#else
|
|
||||||
void GenerateBitcoins(bool fGenerate, int nThreads);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Generate a new block, without valid proof-of-work */
|
/** Generate a new block, without valid proof-of-work */
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
|
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@@ -43,8 +35,18 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
|
|||||||
boost::optional<CScript> GetMinerScriptPubKey();
|
boost::optional<CScript> GetMinerScriptPubKey();
|
||||||
CBlockTemplate* CreateNewBlockWithKey();
|
CBlockTemplate* CreateNewBlockWithKey();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
/** Modify the extranonce in a block */
|
/** Modify the extranonce in a block */
|
||||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
|
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
|
||||||
|
/** Run the miner threads */
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
|
||||||
|
#else
|
||||||
|
void GenerateBitcoins(bool fGenerate, int nThreads);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
||||||
|
|
||||||
#endif // BITCOIN_MINER_H
|
#endif // BITCOIN_MINER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user