mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Refactor/encapsulate chain globals into a CChain class
This commit is contained in:
@@ -176,7 +176,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
int64 nFees = 0;
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
CBlockIndex* pindexPrev = pindexBest;
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
CCoinsViewCache view(*pcoinsTip, true);
|
||||
|
||||
// Priority order to process transactions
|
||||
@@ -467,7 +467,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
// Found a solution
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (pblock->hashPrevBlock != hashBestChain)
|
||||
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
|
||||
return error("BitcoinMiner : generated block is stale");
|
||||
|
||||
// Remove key from key pool
|
||||
@@ -510,7 +510,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
// Create new block
|
||||
//
|
||||
unsigned int nTransactionsUpdatedLast = nTransactionsUpdated;
|
||||
CBlockIndex* pindexPrev = pindexBest;
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
|
||||
if (!pblocktemplate.get())
|
||||
@@ -613,7 +613,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
break;
|
||||
if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
break;
|
||||
if (pindexPrev != pindexBest)
|
||||
if (pindexPrev != chainActive.Tip())
|
||||
break;
|
||||
|
||||
// Update nTime every few seconds
|
||||
|
||||
Reference in New Issue
Block a user