UNPKG

@bsv/wallet-toolbox-client

Version:
129 lines 4.4 kB
import { HeightRange } from './HeightRange'; import { ChaintracksFsApi } from '../Api/ChaintracksFsApi'; import { ChaintracksFetchApi } from '../Api/ChaintracksFetchApi'; import { ChaintracksStorageBase } from '../Storage/ChaintracksStorageBase'; import { Chain } from '../../../../sdk/types'; /** * Descriptive information about a single bulk header file. */ export interface BulkHeaderFileInfo { /** * filename and extension, no path */ fileName: string; /** * chain height of first header in file */ firstHeight: number; /** * count of how many headers the file contains. File size must be 80 * count. */ count: number; /** * prevChainWork is the cummulative chain work up to the first header in this file's data, as a hex string. */ prevChainWork: string; /** * lastChainWork is the cummulative chain work including the last header in this file's data, as a hex string. */ lastChainWork: string; /** * previousHash of first header in file in standard hex string block hash encoding */ prevHash: string; /** * block hash of last header in the file in standard hex string block hash encoding */ lastHash: string | null; /** * file contents single sha256 hash as base64 string */ fileHash: string | null; /** * Which chain: 'main' or 'test' */ chain?: Chain; data?: Uint8Array; /** * true iff these properties should be considered pre-validated, including a valid required fileHash of data (when not undefined). */ validated?: boolean; /** * optional, used for database storage */ fileId?: number; /** * optional, if valid `${sourceUrl}/${fileName}` is the source of this data. */ sourceUrl?: string; } export declare abstract class BulkHeaderFile implements BulkHeaderFileInfo { chain?: Chain | undefined; count: number; data?: Uint8Array<ArrayBufferLike> | undefined; fileHash: string | null; fileId?: number | undefined; fileName: string; firstHeight: number; lastChainWork: string; lastHash: string | null; prevChainWork: string; prevHash: string; sourceUrl?: string | undefined; validated?: boolean | undefined; constructor(info: BulkHeaderFileInfo); abstract readDataFromFile(length: number, offset: number): Promise<Uint8Array | undefined>; get heightRange(): HeightRange; ensureData(): Promise<Uint8Array>; /** * Whenever reloading data from a backing store, validated fileHash must be re-verified * @returns the sha256 hash of the file's data as base64 string. */ computeFileHash(): Promise<string>; releaseData(): Promise<void>; toCdnInfo(): BulkHeaderFileInfo; toStorageInfo(): BulkHeaderFileInfo; } export declare class BulkHeaderFileFs extends BulkHeaderFile { fs: ChaintracksFsApi; rootFolder: string; constructor(info: BulkHeaderFileInfo, fs: ChaintracksFsApi, rootFolder: string); readDataFromFile(length: number, offset: number): Promise<Uint8Array | undefined>; ensureData(): Promise<Uint8Array>; } export declare class BulkHeaderFileStorage extends BulkHeaderFile { storage: ChaintracksStorageBase; fetch: ChaintracksFetchApi; constructor(info: BulkHeaderFileInfo, storage: ChaintracksStorageBase, fetch: ChaintracksFetchApi); readDataFromFile(length: number, offset: number): Promise<Uint8Array | undefined>; ensureData(): Promise<Uint8Array>; } /** * Describes a collection of bulk block header files. */ export interface BulkHeaderFilesInfo { /** * Where this file was fetched or read from. */ rootFolder: string; /** * Sub-path to this resource on rootFolder */ jsonFilename: string; /** * Array of information about each bulk block header file. */ files: BulkHeaderFileInfo[]; /** * Maximum number of headers in a single file in this collection of files. */ headersPerFile: number; } export declare abstract class BulkHeaderFiles implements BulkHeaderFilesInfo { rootFolder: string; jsonFilename: string; files: BulkHeaderFileInfo[]; headersPerFile: number; constructor(rootFolder: string, jsonFilename: string, files: BulkHeaderFileInfo[], headersPerFile: number); } //# sourceMappingURL=BulkHeaderFile.d.ts.map