aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 7c3f885410..660173f35b 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -134,6 +134,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
+ const int nHeight = pindexPrev->nHeight + 1;
CCoinsViewCache view(pcoinsTip);
// Priority order to process transactions
@@ -148,7 +149,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
mi != mempool.mapTx.end(); ++mi)
{
const CTransaction& tx = mi->second.GetTx();
- if (tx.IsCoinBase() || !IsFinalTx(tx, pindexPrev->nHeight + 1))
+ if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight))
continue;
COrphan* porphan = NULL;
@@ -191,7 +192,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
CAmount nValueIn = coins->vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
- int nConf = pindexPrev->nHeight - coins->nHeight + 1;
+ int nConf = nHeight - coins->nHeight;
dPriority += (double)nValueIn * nConf;
}
@@ -279,7 +280,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
continue;
CTxUndo txundo;
- UpdateCoins(tx, state, view, txundo, pindexPrev->nHeight+1);
+ UpdateCoins(tx, state, view, txundo, nHeight);
// Added
pblock->vtx.push_back(tx);
@@ -319,8 +320,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize);
// Compute final coinbase transaction.
- txNew.vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
- txNew.vin[0].scriptSig = CScript() << OP_0 << OP_0;
+ txNew.vout[0].nValue = GetBlockValue(nHeight, nFees);
+ txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
pblock->vtx[0] = txNew;
pblocktemplate->vTxFees[0] = -nFees;
@@ -331,13 +332,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
pblock->nNonce = 0;
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
- CBlockIndex indexDummy(*pblock);
- indexDummy.pprev = pindexPrev;
- indexDummy.nHeight = pindexPrev->nHeight + 1;
- CCoinsViewCache viewNew(pcoinsTip);
CValidationState state;
- if (!ConnectBlock(*pblock, state, &indexDummy, viewNew, true))
- throw std::runtime_error("CreateNewBlock() : ConnectBlock failed");
+ if (!TestBlockValidity(state, *pblock, pindexPrev, false, false))
+ throw std::runtime_error("CreateNewBlock() : TestBlockValidity failed");
}
return pblocktemplate.release();