@pavlovcik/permit2-rpc-manager
Version:
Intelligent RPC manager with Permit2 validation and advanced fallback strategy
33 lines • 1.23 kB
TypeScript
import type { LatencyTestResult } from "./latency-tester.ts";
type LoggerFn = (level: "debug" | "info" | "warn" | "error", message: string, ...optionalParams: any[]) => void;
interface ChainCache {
fastestRpc: string | null;
latencyMap: Record<string, LatencyTestResult>;
lastTested: number;
}
interface CacheManagerOptions {
cacheTtlMs?: number;
localStorageKey?: string;
logger?: LoggerFn;
}
/**
* CacheManager primarily for browser environments using localStorage.
* Node.js file caching is handled separately in cache-manager.node.ts.
*/
export declare class CacheManager {
private cache;
private cacheLoaded;
private cacheKey;
private cacheTtlMs;
private log;
constructor(options?: CacheManagerOptions);
private loadCache;
private saveCache;
private getRawChainCache;
getChainCache(chainId: number): Promise<ChainCache | null>;
updateChainCache(chainId: number, latencyMap: Record<string, LatencyTestResult>, fastestRpc: string | null): Promise<void>;
getFastestRpc(chainId: number): Promise<string | null>;
getLatencyMap(chainId: number): Promise<Record<string, LatencyTestResult> | null>;
}
export {};
//# sourceMappingURL=cache-manager.d.ts.map