import { SchemaTypeDef } from '@based/schema/def'; export declare const destructureTreeKey: (key: number) => number[]; export declare const makeTreeKey: (typeId: number, start: number) => number; export declare const nodeId2Start: (blockCapacity: number, nodeId: number) => number; export declare const makeTreeKeyFromNodeId: (typeId: number, blockCapacity: number, nodeId: number) => number; type Hash = Uint8Array; /** * Block state. * Type and a node id range. */ export type VerifBlock = { /** * key = typeId + startNodeId * Made with makeTreeKey(t, i) and can be destructured with destructureTreeKey(k). */ key: number; /** * Last acquired hash of the block. * This is normally updated at load and save time but never during read/modify ops. */ hash: Hash; /** * If false the block is offloaded to fs; * true doesn't necessarily mean that the block still exists because it could have been deleted. */ inmem: boolean; /** * If set, the block is being loaded and it can be awaited with this promise. */ loadPromise: null | Promise; }; /** * Container for a whole type. */ type VerifType = { typeId: number; /*!< typeId as in the schema. */ blockCapacity: number; /*!< Max number of nodes per block. */ blocks: VerifBlock[]; }; /** * An object that keeps track of all blocks of nodes existing in the database. */ export declare class VerifTree { #private; constructor(schemaTypesParsed: Record); types(): Generator; blocks(type: VerifType): Generator; foreachBlock(cb: (block: VerifBlock) => void): void; get hash(): Uint8Array; update(key: number, hash: Hash, inmem?: boolean): void; remove(key: number): void; static blockSdbFile(typeId: number, start: number, end: number): string; getBlock(key: number): VerifBlock; getBlockFile(block: VerifBlock): string; updateTypes(schemaTypesParsed: Record): void; } export {};