mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge pull request #2115 from forrestv/getblocktemplate_allfees
Provide fee data for all txs in RPC getblocktemplate response
This commit is contained in:
28
src/main.cpp
28
src/main.cpp
@@ -3732,12 +3732,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
CBlock* CreateNewBlock(CReserveKey& reservekey)
|
||||
CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
|
||||
{
|
||||
// Create new block
|
||||
auto_ptr<CBlock> pblock(new CBlock());
|
||||
if (!pblock.get())
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||
if(!pblocktemplate.get())
|
||||
return NULL;
|
||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||
|
||||
// Create coinbase tx
|
||||
CTransaction txNew;
|
||||
@@ -3748,6 +3749,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
||||
|
||||
// Add our coinbase tx as first transaction
|
||||
pblock->vtx.push_back(txNew);
|
||||
pblocktemplate->vTxFees.push_back(-1); // updated at end
|
||||
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
|
||||
|
||||
// Largest block you're willing to create:
|
||||
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
|
||||
@@ -3925,6 +3928,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
||||
|
||||
// Added
|
||||
pblock->vtx.push_back(tx);
|
||||
pblocktemplate->vTxFees.push_back(nTxFees);
|
||||
pblocktemplate->vTxSigOps.push_back(nTxSigOps);
|
||||
nBlockSize += nTxSize;
|
||||
++nBlockTx;
|
||||
nBlockSigOps += nTxSigOps;
|
||||
@@ -3959,13 +3964,15 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
||||
printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
|
||||
|
||||
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
|
||||
pblocktemplate->vTxFees[0] = -nFees;
|
||||
|
||||
// Fill in header
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
pblock->UpdateTime(pindexPrev);
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get());
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock);
|
||||
pblock->nNonce = 0;
|
||||
pblock->vtx[0].vin[0].scriptSig = CScript() << OP_0 << OP_0;
|
||||
pblocktemplate->vTxSigOps[0] = pblock->vtx[0].GetLegacySigOpCount();
|
||||
|
||||
CBlockIndex indexDummy(*pblock);
|
||||
indexDummy.pprev = pindexPrev;
|
||||
@@ -3975,7 +3982,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
||||
throw std::runtime_error("CreateNewBlock() : ConnectBlock failed");
|
||||
}
|
||||
|
||||
return pblock.release();
|
||||
return pblocktemplate.release();
|
||||
}
|
||||
|
||||
|
||||
@@ -4118,10 +4125,11 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
unsigned int nTransactionsUpdatedLast = nTransactionsUpdated;
|
||||
CBlockIndex* pindexPrev = pindexBest;
|
||||
|
||||
auto_ptr<CBlock> pblock(CreateNewBlock(reservekey));
|
||||
if (!pblock.get())
|
||||
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(reservekey));
|
||||
if (!pblocktemplate.get())
|
||||
return;
|
||||
IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce);
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
|
||||
printf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||
@@ -4134,7 +4142,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
char pdatabuf[128+16]; char* pdata = alignup<16>(pdatabuf);
|
||||
char phash1buf[64+16]; char* phash1 = alignup<16>(phash1buf);
|
||||
|
||||
FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1);
|
||||
FormatHashBuffers(pblock, pmidstate, pdata, phash1);
|
||||
|
||||
unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4);
|
||||
unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8);
|
||||
@@ -4170,7 +4178,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
assert(hash == pblock->GetHash());
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
CheckWork(pblock.get(), *pwalletMain, reservekey);
|
||||
CheckWork(pblock, *pwalletMain, reservekey);
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user