export type CID = import('multiformats/cid').CID; export type Datastore = import('interface-datastore').Datastore; /** * @typedef {import('multiformats/cid').CID} CID * @typedef {import('interface-datastore').Datastore} Datastore */ /** * This class manages known providers. * A provider is a peer that we know to have the content for a given CID. * * Every `cleanupInterval` providers are checked if they * are still valid, i.e. younger than the `provideValidity`. * If they are not, they are deleted. * * To ensure the list survives restarts of the daemon, * providers are stored in the datastore, but to ensure * access is fast there is an LRU cache in front of that. */ export class Providers { /** * @param {object} options * @param {Datastore} options.providers * @param {number} [options.cacheSize=256] * @param {number} [options.cleanupInterval] - How often invalid records are cleaned. (in seconds) * @param {number} [options.provideValidity] - How long is a provider valid for. (in seconds) */ constructor({ providers, cacheSize, cleanupInterval, provideValidity }: { providers: Datastore; cacheSize?: number | undefined; cleanupInterval?: number | undefined; provideValidity?: number | undefined; }); datastore: import("interface-datastore").Datastore; cleanupInterval: number; provideValidity: number; cache: any; syncQueue: Queue; /** * Start the provider cleanup service */ start(): void; _started: boolean | undefined; _cleaner: NodeJS.Timer | null | undefined; /** * Release any resources. */ stop(): void; /** * Check all providers if they are still valid, and if not delete them. * * @returns {Promise} * @private */ private _cleanup; /** * Get the currently known provider peer ids for a given CID. * * @param {CID} cid * @returns {Promise>} * * @private */ private _getProvidersMap; /** * Add a new provider for the given CID. * * @param {CID} cid * @param {PeerId} provider * @returns {Promise} */ addProvider(cid: CID, provider: PeerId): Promise; /** * Get a list of providers for the given CID. * * @param {CID} cid * @returns {Promise>} */ getProviders(cid: CID): Promise>; } import { default as Queue } from "p-queue"; import PeerId = require("peer-id"); //# sourceMappingURL=providers.d.ts.map