ByteBlockReader.index.page.start: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader Lines 1643-1654 of mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&start_line=1643&end_line=1654 import Base import mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexPolicy.bend as BlockIndexPolicy import mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend as SHA def index.page.start(file: File, state: State) -> IO(Result<&1, &1, U32 & String, Step>): match state: case State{+size, _, +index_offset, _, +total, _, _, _, root_hash, index_hash, _, _}: +remaining = Nat.sub(size, Nat.add(index_offset, 44n)) +index_length = U32.from_nat(remaining) +page_bytes = BlockIndexPolicy.max_bytes() +pages = Nat.div(Nat.add(remaining, Nat.sub(page_bytes, 1n)), page_bytes) +fuel = Nat.add(Nat.mul(3n, pages), 1n) index.page.loop(fuel, IndexPageNeed{file, IndexMeta{total, index_length, index_hash}, index_offset, remaining, SHA.stream.initial(), root_hash}) Uses (18): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend&name=stream.initial https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/BlockIndexPolicy.bend&name=max_bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=IndexMeta https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=IndexPageState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=State https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=Step https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend&name=index.page.loop