mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #12153: Avoid permanent cs_main lock in getblockheader
f12e1d0b5117e3688f52a25ed0170d76ecdbf233 rpc: Avoid permanent cs_main lock in getblockheader (João Barbosa) Pull request description: This PR reduces the `cs_main` lock scope in `getblockheader` RPC. Tree-SHA512: bc51f80e15d1b32d3c7886836457f9929706b6aad9841dafce31ffca444281471b21b56192bb50de774184b9377412f815ad8d3d2439049a7e64d2e59c415767
This commit is contained in:
parent
2fe566ded9
commit
60d7fd708c
@ -809,8 +809,6 @@ static UniValue getblockheader(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
std::string strHash = request.params[0].get_str();
|
||||
uint256 hash(uint256S(strHash));
|
||||
|
||||
@ -818,7 +816,14 @@ static UniValue getblockheader(const JSONRPCRequest& request)
|
||||
if (!request.params[1].isNull())
|
||||
fVerbose = request.params[1].get_bool();
|
||||
|
||||
const CBlockIndex* pblockindex = LookupBlockIndex(hash);
|
||||
const CBlockIndex* pblockindex;
|
||||
const CBlockIndex* tip;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pblockindex = LookupBlockIndex(hash);
|
||||
tip = chainActive.Tip();
|
||||
}
|
||||
|
||||
if (!pblockindex) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user