|
|
@ -124,6 +124,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, mempool.cs); |
|
|
|
LOCK2(cs_main, mempool.cs); |
|
|
|
CBlockIndex* pindexPrev = chainActive.Tip(); |
|
|
|
CBlockIndex* pindexPrev = chainActive.Tip(); |
|
|
|
|
|
|
|
const int nHeight = pindexPrev->nHeight + 1; |
|
|
|
CCoinsViewCache view(pcoinsTip); |
|
|
|
CCoinsViewCache view(pcoinsTip); |
|
|
|
|
|
|
|
|
|
|
|
// Priority order to process transactions
|
|
|
|
// Priority order to process transactions
|
|
|
@ -138,7 +139,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
mi != mempool.mapTx.end(); ++mi) |
|
|
|
mi != mempool.mapTx.end(); ++mi) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CTransaction& tx = mi->second.GetTx(); |
|
|
|
const CTransaction& tx = mi->second.GetTx(); |
|
|
|
if (tx.IsCoinBase() || !IsFinalTx(tx, pindexPrev->nHeight + 1)) |
|
|
|
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
COrphan* porphan = NULL; |
|
|
|
COrphan* porphan = NULL; |
|
|
@ -181,7 +182,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
CAmount nValueIn = coins->vout[txin.prevout.n].nValue; |
|
|
|
CAmount nValueIn = coins->vout[txin.prevout.n].nValue; |
|
|
|
nTotalIn += nValueIn; |
|
|
|
nTotalIn += nValueIn; |
|
|
|
|
|
|
|
|
|
|
|
int nConf = pindexPrev->nHeight - coins->nHeight + 1; |
|
|
|
int nConf = nHeight - coins->nHeight; |
|
|
|
|
|
|
|
|
|
|
|
dPriority += (double)nValueIn * nConf; |
|
|
|
dPriority += (double)nValueIn * nConf; |
|
|
|
} |
|
|
|
} |
|
|
@ -269,7 +270,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
CTxUndo txundo; |
|
|
|
CTxUndo txundo; |
|
|
|
UpdateCoins(tx, state, view, txundo, pindexPrev->nHeight+1); |
|
|
|
UpdateCoins(tx, state, view, txundo, nHeight); |
|
|
|
|
|
|
|
|
|
|
|
// Added
|
|
|
|
// Added
|
|
|
|
pblock->vtx.push_back(tx); |
|
|
|
pblock->vtx.push_back(tx); |
|
|
@ -309,8 +310,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) |
|
|
|
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize); |
|
|
|
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize); |
|
|
|
|
|
|
|
|
|
|
|
// Compute final coinbase transaction.
|
|
|
|
// Compute final coinbase transaction.
|
|
|
|
txNew.vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees); |
|
|
|
txNew.vout[0].nValue = GetBlockValue(nHeight, nFees); |
|
|
|
txNew.vin[0].scriptSig = CScript() << OP_0 << OP_0; |
|
|
|
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; |
|
|
|
pblock->vtx[0] = txNew; |
|
|
|
pblock->vtx[0] = txNew; |
|
|
|
pblocktemplate->vTxFees[0] = -nFees; |
|
|
|
pblocktemplate->vTxFees[0] = -nFees; |
|
|
|
|
|
|
|
|
|
|
|