@bsv/wallet-toolbox
Version:
BRC100 conforming wallet, wallet storage and wallet signer components
60 lines • 3.26 kB
TypeScript
import { BulkIngestorApi, BulkIngestorBaseOptions, BulkSyncResult } from '../Api/BulkIngestorApi';
import { ChaintracksStorageApi } from '../Api/ChaintracksStorageApi';
import { BulkHeaderFilesInfo } from '../util/BulkHeaderFile';
import { HeightRange, HeightRanges } from '../util/HeightRange';
import { Chain } from '../../../../sdk/types';
import { BlockHeader } from '../Api/BlockHeaderApi';
import { ChaintracksStorageBase } from '../Storage/ChaintracksStorageBase';
export declare abstract class BulkIngestorBase implements BulkIngestorApi {
/**
*
* @param chain
* @param localCachePath defaults to './data/ingest_headers/'
* @returns
*/
static createBulkIngestorBaseOptions(chain: Chain): BulkIngestorBaseOptions;
chain: Chain;
jsonFilename: string;
log: (...args: any[]) => void;
constructor(options: BulkIngestorBaseOptions);
private storageEngine;
setStorage(storage: ChaintracksStorageBase, log: (...args: any[]) => void): Promise<void>;
shutdown(): Promise<void>;
storageOrUndefined(): ChaintracksStorageApi | undefined;
storage(): ChaintracksStorageBase;
/**
* information about locally cached bulk header files managed by this bulk ingestor
*/
filesInfo: BulkHeaderFilesInfo | undefined;
/**
* At least one derived BulkIngestor must override this method to provide the current height of the active chain tip.
* @returns undefined unless overridden
*/
getPresentHeight(): Promise<number | undefined>;
/**
* A BulkIngestor fetches and updates storage with bulk headers in bulkRange.
*
* If it can, it must also fetch live headers in fetch range that are not in bulkRange and return them as an array.
*
* The storage methods `insertBulkFile`, `updateBulkFile`, and `addBulkHeaders` should be used to add bulk headers to storage.
*
* @param before bulk and live range of headers before ingesting any new headers.
* @param fetchRange range of headers still needed, includes both missing bulk and live headers.
* @param bulkRange range of bulk headers still needed
* @param priorLiveHeaders any headers accumulated by prior bulk ingestor(s) that are too recent for bulk storage.
* @returns new live headers: headers in fetchRange but not in bulkRange
*/
abstract fetchHeaders(before: HeightRanges, fetchRange: HeightRange, bulkRange: HeightRange, priorLiveHeaders: BlockHeader[]): Promise<BlockHeader[]>;
/**
* A BulkIngestor has two potential goals:
* 1. To source missing bulk headers and include them in bulk storage.
* 2. To source missing live headers to be forwarded to live storage.
*
* @param presentHeight current height of the active chain tip, may lag the true value.
* @param before current bulk and live storage height ranges, either may be empty.
* @param priorLiveHeaders any headers accumulated by prior bulk ingestor(s) that are too recent for bulk storage.
* @returns updated priorLiveHeaders including any accumulated by this ingestor
*/
synchronize(presentHeight: number, before: HeightRanges, priorLiveHeaders: BlockHeader[]): Promise<BulkSyncResult>;
}
//# sourceMappingURL=BulkIngestorBase.d.ts.map