diff options
author | Forrest Voight <forrest@forre.st> | 2012-12-19 15:21:21 -0500 |
---|---|---|
committer | Forrest Voight <forrest@forre.st> | 2012-12-19 16:12:58 -0500 |
commit | 03cac0bb8e9cab02c456cbe71a0519aec92a6150 (patch) | |
tree | 9dd3dfd63a244690a13c2622873f2bf3f855be71 /src/rpcmining.cpp | |
parent | 6940626d08e313c5e1cd99c63aeca9da45d5b7a4 (diff) |
changed CreateNewBlock to return a CBlockTemplate object, which includes per-tx fee and sigop count data
Diffstat (limited to 'src/rpcmining.cpp')
-rw-r--r-- | src/rpcmining.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 0591f35392..e4b487aea4 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -103,7 +103,7 @@ Value getwork(const Array& params, bool fHelp) typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; static mapNewBlock_t mapNewBlock; // FIXME: thread safety - static vector<CBlock*> vNewBlock; + static vector<CBlockTemplate*> vNewBlockTemplate; static CReserveKey reservekey(pwalletMain); if (params.size() == 0) @@ -112,7 +112,7 @@ Value getwork(const Array& params, bool fHelp) static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64 nStart; - static CBlock* pblock; + static CBlockTemplate* pblocktemplate; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)) { @@ -120,9 +120,9 @@ Value getwork(const Array& params, bool fHelp) { // Deallocate old blocks since they're obsolete now mapNewBlock.clear(); - BOOST_FOREACH(CBlock* pblock, vNewBlock) - delete pblock; - vNewBlock.clear(); + BOOST_FOREACH(CBlockTemplate* pblocktemplate, vNewBlockTemplate) + delete pblocktemplate; + vNewBlockTemplate.clear(); } // Clear pindexPrev so future getworks make a new block, despite any failures from here on @@ -134,14 +134,15 @@ Value getwork(const Array& params, bool fHelp) nStart = GetTime(); // Create new block - pblock = CreateNewBlock(reservekey); - if (!pblock) + pblocktemplate = CreateNewBlock(reservekey); + if (!pblocktemplate) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); - vNewBlock.push_back(pblock); + vNewBlockTemplate.push_back(pblocktemplate); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } + CBlock* pblock = &pblocktemplate->block; // pointer for convenience // Update nTime pblock->UpdateTime(pindexPrev); @@ -248,7 +249,7 @@ Value getblocktemplate(const Array& params, bool fHelp) static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64 nStart; - static CBlock* pblock; + static CBlockTemplate* pblocktemplate; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { @@ -261,18 +262,19 @@ Value getblocktemplate(const Array& params, bool fHelp) nStart = GetTime(); // Create new block - if(pblock) + if(pblocktemplate) { - delete pblock; - pblock = NULL; + delete pblocktemplate; + pblocktemplate = NULL; } - pblock = CreateNewBlock(reservekey); - if (!pblock) + pblocktemplate = CreateNewBlock(reservekey); + if (!pblocktemplate) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } + CBlock* pblock = &pblocktemplate->block; // pointer for convenience // Update nTime pblock->UpdateTime(pindexPrev); |