UNPKG

@bsv/wallet-toolbox

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

76 lines 3.5 kB
import { Chain } from '../../../../sdk/types'; import { BlockHeader } from '../Api/BlockHeaderApi'; import { BulkIngestorBaseOptions } from '../Api/BulkIngestorApi'; import { BulkIngestorBase } from './BulkIngestorBase'; import { BulkHeaderFileInfo } from '../util/BulkHeaderFile'; import { BulkHeaderFilesInfo } from '../util/BulkHeaderFile'; import { HeightRange, HeightRanges } from '../util/HeightRange'; import { ChaintracksFetchApi } from '../Api/ChaintracksFetchApi'; export interface BulkIngestorCDNOptions extends BulkIngestorBaseOptions { /** * Required. * * The name of the JSON resource to request from CDN which describes currently * available bulk block header resources. */ jsonResource: string | undefined; /** * Required. * * URL to CDN implementing the bulk ingestor CDN service protocol */ cdnUrl: string | undefined; maxPerFile: number | undefined; fetch: ChaintracksFetchApi; } export declare class BulkIngestorCDN extends BulkIngestorBase { /** * * @param chain * @param localCachePath defaults to './data/bulk_cdn_headers/' * @returns */ static createBulkIngestorCDNOptions(chain: Chain, cdnUrl: string, fetch: ChaintracksFetchApi, maxPerFile?: number): BulkIngestorCDNOptions; fetch: ChaintracksFetchApi; jsonResource: string; cdnUrl: string; maxPerFile: number | undefined; availableBulkFiles: BulkHeaderFilesInfo | undefined; selectedFiles: BulkHeaderFileInfo[] | undefined; currentRange: HeightRange | undefined; constructor(options: BulkIngestorCDNOptions); getPresentHeight(): Promise<number | undefined>; getJsonHttpHeaders(): Record<string, string>; /** * A BulkFile CDN serves a JSON BulkHeaderFilesInfo resource which lists all the available binary bulk header files available and associated metadata. * * The term "CDN file" is used for a local bulk file that has a sourceUrl. (Not undefined) * The term "incremental file" is used for the local bulk file that holds all the non-CDN bulk headers and must chain to the live headers if there are any. * * Bulk ingesting from a CDN happens in one of three contexts: * * 1. Cold Start: No local bulk or live headers. * 2. Incremental: Available CDN files extend into an existing incremental file but not into the live headers. * 3. Replace: Available CDN files extend into live headers. * * Context Cold Start: * - The CDN files are selected in height order, starting at zero, always choosing the largest count less than the local maximum (maxPerFile). * * Context Incremental: * - Last existing CDN file is updated if CDN now has a higher count. * - Additional CDN files are added as in Cold Start. * - The existing incremental file is truncated or deleted. * * Context Replace: * - Existing live headers are truncated or deleted. * - Proceed as context Incremental. * * @param before bulk and live range of headers before ingesting any new headers. * @param fetchRange total range of header heights needed including live headers * @param bulkRange range of missing bulk header heights required. * @param priorLiveHeaders * @returns */ fetchHeaders(before: HeightRanges, fetchRange: HeightRange, bulkRange: HeightRange, priorLiveHeaders: BlockHeader[]): Promise<BlockHeader[]>; } //# sourceMappingURL=BulkIngestorCDN.d.ts.map