@@ -124,6 +124,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
124
124
{
125
125
LOCK2 (cs_main, mempool.cs );
126
126
CBlockIndex* pindexPrev = chainActive.Tip ();
127
+ const int nHeight = pindexPrev->nHeight + 1 ;
127
128
CCoinsViewCache view (pcoinsTip);
128
129
129
130
// Priority order to process transactions
@@ -138,7 +139,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
138
139
mi != mempool.mapTx .end (); ++mi)
139
140
{
140
141
const CTransaction& tx = mi->second .GetTx ();
141
- if (tx.IsCoinBase () || !IsFinalTx (tx, pindexPrev-> nHeight + 1 ))
142
+ if (tx.IsCoinBase () || !IsFinalTx (tx, nHeight))
142
143
continue ;
143
144
144
145
COrphan* porphan = NULL ;
@@ -181,7 +182,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
181
182
CAmount nValueIn = coins->vout [txin.prevout .n ].nValue ;
182
183
nTotalIn += nValueIn;
183
184
184
- int nConf = pindexPrev-> nHeight - coins->nHeight + 1 ;
185
+ int nConf = nHeight - coins->nHeight ;
185
186
186
187
dPriority += (double )nValueIn * nConf;
187
188
}
@@ -269,7 +270,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
269
270
continue ;
270
271
271
272
CTxUndo txundo;
272
- UpdateCoins (tx, state, view, txundo, pindexPrev-> nHeight + 1 );
273
+ UpdateCoins (tx, state, view, txundo, nHeight);
273
274
274
275
// Added
275
276
pblock->vtx .push_back (tx);
@@ -309,8 +310,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
309
310
LogPrintf (" CreateNewBlock(): total size %u\n " , nBlockSize);
310
311
311
312
// Compute final coinbase transaction.
312
- txNew.vout [0 ].nValue = GetBlockValue (pindexPrev-> nHeight + 1 , nFees);
313
- txNew.vin [0 ].scriptSig = CScript () << OP_0 << OP_0;
313
+ txNew.vout [0 ].nValue = GetBlockValue (nHeight, nFees);
314
+ txNew.vin [0 ].scriptSig = CScript () << nHeight << OP_0;
314
315
pblock->vtx [0 ] = txNew;
315
316
pblocktemplate->vTxFees [0 ] = -nFees;
316
317
0 commit comments