Mercurial > hg > bitcoin
changeset 3256:d6ad8e055d9b draft
Merge branch 'bugfix_CNBerr' of git://github.com/luke-jr/bitcoin
author | Gavin Andresen <gavinandresen@gmail.com> |
---|---|
date | Thu, 26 Jul 2012 13:55:21 -0400 |
parents | 916cfcc0146a (current diff) 214adc2f83a4 (diff) |
children | 5fd894daaefe |
files | src/bitcoinrpc.cpp |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1851,8 +1851,13 @@ delete pblock; vNewBlock.clear(); } + + // Clear pindexPrev so future getworks make a new block, despite any failures from here on + pindexPrev = NULL; + + // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; - pindexPrev = pindexBest; + CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block @@ -1860,6 +1865,9 @@ if (!pblock) throw JSONRPCError(-7, "Out of memory"); vNewBlock.push_back(pblock); + + // Need to update only after we know CreateNewBlock succeeded + pindexPrev = pindexPrevNew; } // Update nTime @@ -1950,16 +1958,26 @@ if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { + // Clear pindexPrev so future calls make a new block, despite any failures from here on + pindexPrev = NULL; + + // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; - pindexPrev = pindexBest; + CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block if(pblock) + { delete pblock; + pblock = NULL; + } pblock = CreateNewBlock(reservekey); if (!pblock) throw JSONRPCError(-7, "Out of memory"); + + // Need to update only after we know CreateNewBlock succeeded + pindexPrev = pindexPrevNew; } // Update nTime