Description

FetchBlockRegions returns the raw serialized bytes for the given block regions.

For example, it is possible to directly extract Bitcoin transactions and/or scripts from various blocks with this function. Depending on the backend implementation, this can provide significant savings by avoiding the need to load entire blocks.

The raw bytes are in the format returned by Serialize on a wire.MsgBlock and the Offset fields in the provided BlockRegions are zero-based and relative to the start of the block (byte 0).

The interface contract guarantees at least the following errors will be returned (other implementation-specific errors are possible):

- ErrBlockNotFound if any of the requested block hashed do not
  exist
- ErrBlockRegionInvalid if one or more region exceed the bounds of
  the associated block
- ErrTxClosed if the transaction has already been closed
- ErrCorruption if the database has somehow become corrupted

NOTE: The data returned by this function is only valid during a database transaction. Attempting to access it after a transaction has ended results in undefined behavior. This constraint prevents additional data copies and allows support for memory-mapped database implementations.

FetchBlockRegions is referenced in 2 repositories

github.com/btcsuite/btcd

...