import { open } from 'lmdb'; import { TrawlerOptions, Progress } from '../types'; import { EventEmitter } from 'tseep'; import { Logger } from '../utils'; export default class NTTrawler extends EventEmitter { protected queue: any; protected relays: string[]; protected promises: Promise[]; protected defaults: TrawlerOptions; protected options: TrawlerOptions; protected cache: ReturnType | null; protected logger: Logger; constructor(relays: string[], options?: Partial); run(): Promise; countEvents(relay: string): Promise; countTimestamps(relay: string): Promise; openCache(): Promise; trawl(chunk: string[], $job: any): Promise; /** * Race a promise against a timeout. Cleans up the timer and suppresses * late rejections from the original promise (e.g. after relay.close()). */ private withTimeout; private trawlRelay; private trawlWithNegentropy; private trawlWithRequest; private processEvent; /** * Retrieve cached events for use as the negentropy local store. * Capped to prevent OOM — negentropy reconciliation works fine with a * subset; it just means we may re-download some events we already have, * which the dedup check in processEvent() will discard cheaply. */ private getCachedEvents; /** * Get cached NIP-77 capability result for a relay. * Returns null if not cached or if the cache entry has expired. */ private getNip77Cache; /** * Cache the NIP-77 capability result for a relay. */ private setNip77Cache; addRelays(newRelays: string[]): void; chunk_relays(): string[][]; getSince(relay: string): number; updateSince(key: string, timestamp: number): Promise; updateProgress(progress: Progress, $job: any): Promise; pause(): void; resume(): void; protected addJob(index: number, chunk: string[]): Promise; }