aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <[email protected]>2012-05-09 17:02:07 +0000
committerLuke Dashjr <[email protected]>2012-05-09 17:02:07 +0000
commitb354251f1aa2e98585de0942d1fb4f1ec599a39b (patch)
tree6b76d88b2887b2de72af384dbd40e666f3bd3952
parentnew getwork (diff)
downloaddiscoin-b354251f1aa2e98585de0942d1fb4f1ec599a39b.tar.xz
discoin-b354251f1aa2e98585de0942d1fb4f1ec599a39b.zip
Bugfix: getwork: NULL pindexPrev across CreateNewBlock, in case it fails
-rw-r--r--rpc.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/rpc.cpp b/rpc.cpp
index 113de85a9..a579a5d90 100644
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -967,8 +967,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
@@ -976,6 +981,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