Skip to content

Commit

Permalink
Add LOCK to LookupBlockIndex to avoid deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
wagerr-builder committed Jun 25, 2023
1 parent 346660f commit c826186
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tokens/rpctokenwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,11 @@ extern UniValue listtokenssinceblock(const JSONRPCRequest& request)
uint256 blockId;

blockId.SetHex(request.params[curparam].get_str());
pindex = LookupBlockIndex(blockId);

{ // Start of scope for cs_main lock
LOCK(cs_main);
pindex = LookupBlockIndex(blockId);
} // End of scope for cs_main lock, lock is automatically released here
}

curparam++;
Expand Down

0 comments on commit c826186

Please sign in to comment.