- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
26 lines
972 B
TypeScript
26 lines
972 B
TypeScript
|
|
function extractDataFromBlock (block: Uint8Array, blockStart: bigint, requestedStart: bigint, requestedEnd: bigint): Uint8Array {
|
|
const blockLength = BigInt(block.length)
|
|
const blockEnd = BigInt(blockStart + blockLength)
|
|
|
|
if (requestedStart >= blockEnd || requestedEnd < blockStart) {
|
|
// If we are looking for a byte range that is starts after the start of the block,
|
|
// return an empty block. This can happen when internal nodes contain data
|
|
return new Uint8Array(0)
|
|
}
|
|
|
|
if (requestedEnd >= blockStart && requestedEnd < blockEnd) {
|
|
// If the end byte is in the current block, truncate the block to the end byte
|
|
block = block.subarray(0, Number(requestedEnd - blockStart))
|
|
}
|
|
|
|
if (requestedStart >= blockStart && requestedStart < blockEnd) {
|
|
// If the start byte is in the current block, skip to the start byte
|
|
block = block.subarray(Number(requestedStart - blockStart))
|
|
}
|
|
|
|
return block
|
|
}
|
|
|
|
export default extractDataFromBlock
|