aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-03-31 20:35:04 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2015-04-01 11:47:10 -0700
commite2edf95cd3f43331843676e49a82830128a95050 (patch)
tree45a1f675182b1570704d14b1a7d8125fb5b3b8b5 /src/miner.cpp
parent6b04508e37c5dd18cec1cd61cc4356bd208aa991 (diff)
Bugfix: make CreateNewBlock return pindexPrev
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index fdbc47a1c3..7f01918eef 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -87,7 +87,7 @@ void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev)
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
}
-CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
+CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CBlockIndex*& pindexPrev)
{
// Create new block
auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
@@ -132,7 +132,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{
LOCK2(cs_main, mempool.cs);
- CBlockIndex* pindexPrev = chainActive.Tip();
+ pindexPrev = chainActive.Tip();
const int nHeight = pindexPrev->nHeight + 1;
CCoinsViewCache view(pcoinsTip);
@@ -385,14 +385,14 @@ bool static ScanHash(CBlockHeader *pblock, uint256 *phash)
}
}
-CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
+CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, CBlockIndex*& pindexPrev)
{
CPubKey pubkey;
if (!reservekey.GetReservedKey(pubkey))
return NULL;
CScript scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
- return CreateNewBlock(scriptPubKey);
+ return CreateNewBlock(scriptPubKey, pindexPrev);
}
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
@@ -452,9 +452,9 @@ bool MineBlock(CWallet *pwallet, uint256& hash)
unsigned int nExtraNonce = 0;
while (true) {
- CBlockIndex *pindexPrev = chainActive.Tip(); // Actually needs cs_main...
+ CBlockIndex *pindexPrev;
- auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
+ auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey, pindexPrev));
if (!pblocktemplate.get()) {
return false;
}
@@ -497,9 +497,9 @@ void static BitcoinMiner(CWallet *pwallet)
// Create new block
//
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
- CBlockIndex* pindexPrev = chainActive.Tip(); // Actually needs cs_main...
+ CBlockIndex* pindexPrev;
- auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
+ auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey, pindexPrev));
if (!pblocktemplate.get())
{
LogPrintf("Error in BitcoinMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");