blockstorage: allow reading partial block data from storage

It will allow fetching specific transactions using an external index,
following https://github.com/bitcoin/bitcoin/pull/32541#issuecomment-3267485313.

No logging takes place in case of an invalid offset/size (to avoid spamming the log),
by using a new `ReadRawError::BadPartRange` error variant.

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
This commit is contained in:
Roman Zeyde
2025-12-06 15:02:29 +01:00
parent f2fd1aa21c
commit 4e2af1c065
4 changed files with 75 additions and 2 deletions

View File

@@ -420,6 +420,7 @@ static bool rest_block(const std::any& context,
if (!block_data) {
switch (block_data.error()) {
case node::ReadRawError::IO: return RESTERR(req, HTTP_INTERNAL_SERVER_ERROR, "I/O error reading " + hashStr);
case node::ReadRawError::BadPartRange: break; // can happen only when reading a block part
}
assert(false);
}