From c75e3d2772b00acc3850f72a8cb733a0345aa773 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Thu, 13 Oct 2022 15:19:57 -0400 Subject: [PATCH] rest: reduce LOCK(cs_main) scope in rest_block --- src/rest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rest.cpp b/src/rest.cpp index a10d8a433f3..033e93468e6 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -305,8 +305,10 @@ static bool rest_block(const std::any& context, if (chainman.m_blockman.IsBlockPruned(pblockindex)) return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)"); - if (!ReadBlockFromDisk(block, pblockindex, chainman.GetParams().GetConsensus())) - return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); + } + + if (!ReadBlockFromDisk(block, pblockindex, chainman.GetParams().GetConsensus())) { + return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } switch (rf) {