Fix missing lock in submitblock
Rebased-From: eb63bf86cf
Github-Pull: #6007
This commit is contained in:
parent
34127c77cb
commit
eae305f4c4
|
@ -637,14 +637,19 @@ Value submitblock(const Array& params, bool fHelp)
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
|
||||||
|
|
||||||
uint256 hash = block.GetHash();
|
uint256 hash = block.GetHash();
|
||||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
bool fBlockPresent = false;
|
||||||
if (mi != mapBlockIndex.end()) {
|
{
|
||||||
CBlockIndex *pindex = mi->second;
|
LOCK(cs_main);
|
||||||
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||||
return "duplicate";
|
if (mi != mapBlockIndex.end()) {
|
||||||
if (pindex->nStatus & BLOCK_FAILED_MASK)
|
CBlockIndex *pindex = mi->second;
|
||||||
return "duplicate-invalid";
|
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||||
// Otherwise, we might only have the header - process the block before returning
|
return "duplicate";
|
||||||
|
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;
|
CValidationState state;
|
||||||
|
@ -652,7 +657,7 @@ Value submitblock(const Array& params, bool fHelp)
|
||||||
RegisterValidationInterface(&sc);
|
RegisterValidationInterface(&sc);
|
||||||
bool fAccepted = ProcessNewBlock(state, NULL, &block);
|
bool fAccepted = ProcessNewBlock(state, NULL, &block);
|
||||||
UnregisterValidationInterface(&sc);
|
UnregisterValidationInterface(&sc);
|
||||||
if (mi != mapBlockIndex.end())
|
if (fBlockPresent)
|
||||||
{
|
{
|
||||||
if (fAccepted && !sc.found)
|
if (fAccepted && !sc.found)
|
||||||
return "duplicate-inconclusive";
|
return "duplicate-inconclusive";
|
||||||
|
|
Loading…
Reference in New Issue