import { type PublicSignKey } from "@peerbit/crypto"; import type * as types from "@peerbit/document-interface"; export declare const idAgnosticQueryKey: (query: types.SearchRequest | types.SearchRequestIndexed | types.IterationRequest) => string; export interface QueryPredictor { onRequest: (request: types.SearchRequest | types.SearchRequestIndexed | types.IterationRequest, ctx: { from: PublicSignKey; }) => { ignore: boolean; }; predictedQuery: (from: PublicSignKey) => types.SearchRequest | types.SearchRequestIndexed | types.IterationRequest | undefined; } /** * Learns the most common recent queries and predicts the most frequent one. * If we just pre-empted a peer with some query, the *first* matching request * that arrives from that peer within `ignoreWindow` ms is ignored. */ export default class MostCommonQueryPredictor implements QueryPredictor { private readonly threshold; private readonly ttl; private readonly ignoreWindow; private readonly queries; /** * predicted: * requestKey → Map */ private readonly predicted; constructor(threshold: number, ttl?: number, // 10 min ignoreWindow?: number); private cleanupQueries; private cleanupPredictions; onRequest(request: types.SearchRequest | types.SearchRequestIndexed, { from }: { from: PublicSignKey; }): { ignore: boolean; }; predictedQuery(from: PublicSignKey): types.SearchRequest | types.SearchRequestIndexed | undefined; } //# sourceMappingURL=most-common-query-predictor.d.ts.map