Mercurial > hg > bitcoin
changeset 2446:214adc2f83a4 draft
Bugfix: getmemorypool: NULL pindexPrev across CreateNewBlock, in case it fails
author | Luke Dashjr <luke-jr+git@utopios.org> |
---|---|
date | Wed, 09 May 2012 17:08:39 +0000 |
parents | 28d9422ecd90 |
children | d6ad8e055d9b |
files | src/bitcoinrpc.cpp |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1760,16 +1760,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