mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Fix missing lock in submitblock
This commit is contained in:
parent
9125c08f34
commit
eb63bf86cf
@ -629,14 +629,19 @@ Value submitblock(const Array& params, bool fHelp)
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
|
||||
|
||||
uint256 hash = block.GetHash();
|
||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||
if (mi != mapBlockIndex.end()) {
|
||||
CBlockIndex *pindex = mi->second;
|
||||
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||
return "duplicate";
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK)
|
||||
return "duplicate-invalid";
|
||||
// Otherwise, we might only have the header - process the block before returning
|
||||
bool fBlockPresent = false;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||
if (mi != mapBlockIndex.end()) {
|
||||
CBlockIndex *pindex = mi->second;
|
||||
if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||
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;
|
||||
@ -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…
Reference in New Issue
Block a user