Skip to content

Commit efd82ae

Browse files
committed
rpc: reduce LOCK(cs_main) scope in blockToJSON
1 parent f00808e commit efd82ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn
181181
case TxVerbosity::SHOW_DETAILS:
182182
case TxVerbosity::SHOW_DETAILS_AND_PREVOUT:
183183
CBlockUndo blockUndo;
184-
const bool have_undo{WITH_LOCK(::cs_main, return !blockman.IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex))};
184+
const bool is_not_pruned{WITH_LOCK(::cs_main, return !blockman.IsBlockPruned(blockindex))};
185+
const bool have_undo{is_not_pruned && UndoReadFromDisk(blockUndo, blockindex)};
185186

186187
for (size_t i = 0; i < block.vtx.size(); ++i) {
187188
const CTransactionRef& tx = block.vtx.at(i);

0 commit comments

Comments
 (0)