Browse Source

Fix missing lock in submitblock

0.13
Matt Corallo 10 years ago
parent
commit
eb63bf86cf
  1. 7
      src/rpcmining.cpp

7
src/rpcmining.cpp

@ -629,6 +629,9 @@ Value submitblock(const Array& params, bool fHelp) @@ -629,6 +629,9 @@ Value submitblock(const Array& params, bool fHelp)
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
uint256 hash = block.GetHash();
bool fBlockPresent = false;
{
LOCK(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end()) {
CBlockIndex *pindex = mi->second;
@ -637,6 +640,8 @@ Value submitblock(const Array& params, bool fHelp) @@ -637,6 +640,8 @@ Value submitblock(const Array& params, bool fHelp)
if (pindex->nStatus & BLOCK_FAILED_MASK)
return "duplicate-invalid";
// Otherwise, we might only have the header - process the block before returning
fBlockPresent = true;
}
}
CValidationState state;
@ -644,7 +649,7 @@ Value submitblock(const Array& params, bool fHelp) @@ -644,7 +649,7 @@ Value submitblock(const Array& params, bool fHelp)
RegisterValidationInterface(&sc);
bool fAccepted = ProcessNewBlock(state, NULL, &block);
UnregisterValidationInterface(&sc);
if (mi != mapBlockIndex.end())
if (fBlockPresent)
{
if (fAccepted && !sc.found)
return "duplicate-inconclusive";

Loading…
Cancel
Save