Skip to content

Commit e5b537b

Browse files
committed
rest: improve error when only header of a block is available.
This avoids calling ReadRawBlockFromDisk() when the block is expected not to be available because we haven't downloaded it yet and only know the header.
1 parent cf0120f commit e5b537b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/rest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,11 @@ static bool rest_block(const std::any& context,
309309
if (!pblockindex) {
310310
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
311311
}
312-
if (chainman.m_blockman.IsBlockPruned(*pblockindex)) {
313-
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
312+
if (!(pblockindex->nStatus & BLOCK_HAVE_DATA)) {
313+
if (chainman.m_blockman.IsBlockPruned(*pblockindex)) {
314+
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
315+
}
316+
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (not fully downloaded)");
314317
}
315318
pos = pblockindex->GetBlockPos();
316319
}

0 commit comments

Comments
 (0)