mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 09:53:47 +01:00
rpc: reduce LOCK(cs_main) scope in GetUndoChecked and getblockstats
This commit is contained in:
parent
efd82aec8a
commit
4d92b5aaba
@ -600,17 +600,19 @@ static CBlock GetBlockChecked(BlockManager& blockman, const CBlockIndex* pblocki
|
||||
return block;
|
||||
}
|
||||
|
||||
static CBlockUndo GetUndoChecked(BlockManager& blockman, const CBlockIndex* pblockindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
static CBlockUndo GetUndoChecked(BlockManager& blockman, const CBlockIndex* pblockindex)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
CBlockUndo blockUndo;
|
||||
|
||||
// The Genesis block does not have undo data
|
||||
if (pblockindex->nHeight == 0) return blockUndo;
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (blockman.IsBlockPruned(pblockindex)) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Undo data not available (pruned data)");
|
||||
}
|
||||
}
|
||||
|
||||
if (!UndoReadFromDisk(blockUndo, pblockindex)) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Can't read undo data from disk");
|
||||
@ -1799,7 +1801,6 @@ static RPCHelpMan getblockstats()
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||
LOCK(cs_main);
|
||||
const CBlockIndex& pindex{*CHECK_NONFATAL(ParseHashOrHeight(request.params[0], chainman))};
|
||||
|
||||
std::set<std::string> stats;
|
||||
|
Loading…
Reference in New Issue
Block a user