def open.hash.root
mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:248
import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader
import Base
import mylsm-lsm-store@0.6.0.1/src/ByteSstFile.bend as ByteSstFile
import mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend as SHA
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
248def open.hash.root(
249 file: File,
250 +size: Nat,
251 header: Bytes.Bytes,
252 total: U32,
253 counts: Nat & Nat,
254 index_offset: Nat,
255 result: Result<&1, &1, SHA.StreamError, SHA.Stream>
256) -> IO(Result<&1, &1, U32 & String, Reader>):
257 match counts:
258 case (for_reader, for_prefix):
259 match result:
260 case Fail{_}:
261 open.failed(file, resource_limit("SST metadata exceeds the SHA-256 input limit"))
262 case Done{root_hash}:
263 open.hash.index(file, size, header, total, U32.from_nat(for_reader),
264 index_offset, root_hash,
265 SHA.stream.update(SHA.stream.initial(), Bytes.concat([
266 ByteSstFile.index.magic(),
267 ByteSstFile.u32.bytes(U32.from_nat(for_prefix))])))