|
|
@ -387,30 +387,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
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 |
|
|
|
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey) |
|
|
|
#else |
|
|
@ -453,7 +429,32 @@ CBlockTemplate* CreateNewBlockWithKey() |
|
|
|
return CreateNewBlock(*scriptPubKey); |
|
|
|
} |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Internal miner
|
|
|
|
//
|
|
|
|
|
|
|
|
#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 |
|
|
|
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) |
|
|
|
#else |
|
|
|