diff options
| author | Luke Dashjr <[email protected]> | 2012-05-09 17:14:08 +0000 |
|---|---|---|
| committer | Luke Dashjr <[email protected]> | 2012-05-09 17:14:08 +0000 |
| commit | 5146599b01114c568f2a8c02e1ddf8846b95d675 (patch) | |
| tree | 408410b4f8d25614c2cd24a90c6973b0411f05d0 /src/bitcoinrpc.cpp | |
| parent | close old db when rewriting (diff) | |
| parent | Bugfix: getwork: NULL pindexPrev across CreateNewBlock, in case it fails (diff) | |
| download | discoin-5146599b01114c568f2a8c02e1ddf8846b95d675.tar.xz discoin-5146599b01114c568f2a8c02e1ddf8846b95d675.zip | |
Merge branch 'bugfix_CNBerr_daggy' into bugfix_CNBerr
Conflicts:
rpc.cpp
Diffstat (limited to 'src/bitcoinrpc.cpp')
| -rw-r--r-- | src/bitcoinrpc.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 31ef725d7..05913cd0f 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1656,8 +1656,13 @@ Value getwork(const Array& params, bool fHelp) 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 @@ -1665,6 +1670,9 @@ Value getwork(const Array& params, bool fHelp) 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 |