import type { ChainTracker } from '@bsv/sdk'; import type { ChaintracksClientApi } from './chaintracks/Api/ChaintracksClientApi'; /** @public */ export type LocalChainTrackerMode = 'local-primary' | 'remote-only'; /** @public */ export type LocalChainTrackerConsistency = 'unchecked' | 'agreed' | 'lagging' | 'diverged' | 'insufficient-references' | 'error'; /** @public */ export interface LocalChainTrackerRecoveryEvidence { reason: 'lagging' | 'diverged'; localHeight: number; referenceHeight: number; heightLag: number; comparisonHeight: number; expectedHash: string; referenceAgreement: number; } /** @public */ export interface LocalChainTrackerStatus { mode: LocalChainTrackerMode; activeSource: string; consistency: LocalChainTrackerConsistency; localHeight?: number; localTipHash?: string; referenceHeight?: number; heightLag?: number; comparisonHeight?: number; expectedHash?: string; referenceAgreement?: number; checkedAt?: string; recoveredAt?: string; lastFallbackAt?: string; lastError?: string; } /** @public */ export interface LocalChainTrackerOptions { /** Locally persisted, proof-of-work-validating ChainTracks client. */ local: ChaintracksClientApi; /** Independent references used for diagnostics and exceptional fallback. */ fallbacks?: ChaintracksClientApi[]; mode?: LocalChainTrackerMode; fallbackOnLocalError?: boolean; /** Number of matching references needed for a fallback validation result. */ requiredFallbackAgreement?: number; /** Number of matching references needed to declare local divergence. */ requiredConsistencyAgreement?: number; /** Quorum-backed height lag tolerated before local state is considered stuck. */ maxHeightLag?: number; autoRecover?: boolean; /** Clears/reseeds local state and returns the replacement local client. */ recoverLocal?: (evidence: LocalChainTrackerRecoveryEvidence) => Promise; /** Clears local state and returns a fresh local client. */ clearLocal?: () => Promise; now?: () => Date; } /** * Local-first SDK ChainTracker with explicit management and fallback state. * * A definitive local `false` validation is never overridden by a remote * source. Fallback is reserved for local exceptions or explicit remote-only * mode, and applications can require agreement across multiple independent * references before accepting a fallback result. * * @public */ export declare class LocalChainTracker implements ChainTracker { private local; private readonly fallbacks; private readonly fallbackOnLocalError; private readonly requiredFallbackAgreement; private readonly requiredConsistencyAgreement; private readonly maxHeightLag; private readonly autoRecover; private readonly recoverLocal; private readonly clearLocal; private readonly now; private verificationContext; private resetting; private eventEpoch; private observerGeneration; private readonly eventSubscriptions; private readonly eventSetups; private status; constructor(options: LocalChainTrackerOptions); getMode(): LocalChainTrackerMode; setMode(mode: LocalChainTrackerMode): void; /** Local mode/source generation marker for consumers that invalidate derived verdicts. */ getVerificationContext(): string; /** * Fresh token for providers participating in this attempt's canonical authority. * Remote-only uses fallbacks only; local-primary uses the local client only. * A missing participating identity fails closed. Unused providers are omitted * and cannot stand in. This is not an atomic multi-source snapshot. */ getVerificationContextToken(signal?: AbortSignal): Promise; dispose(): Promise; getStatus(): LocalChainTrackerStatus; getLocalClient(): ChaintracksClientApi; currentHeight(): Promise; isValidRootForHeight(root: string, height: number): Promise; synchronize(): Promise; clearLocalData(): Promise; checkConsistency(): Promise; private checkConsistencyInternal; private fallbackHeight; private attemptSources; private sameSources; private applyReset; private sourceContext; private assertCurrentContext; private throwIfAborted; private beginReset; private assertResetOwner; private reorgSubscribe; private ensureEventObservers; private fallbackValidation; private recordFallback; private recordError; private errorMessage; private validateAgreement; private validateHeightLag; } //# sourceMappingURL=LocalChainTracker.d.ts.map