mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-02 13:53:12 +00:00
chore(sds): allow specifying lookback time range for store query
This commit is contained in:
parent
79dd001b1f
commit
d136595d18
@ -26,6 +26,12 @@ export interface QueryOnConnectOptions {
|
||||
* @default [[DEFAULT_FORCE_QUERY_THRESHOLD_MS]]
|
||||
*/
|
||||
forceQueryThresholdMs?: number;
|
||||
/**
|
||||
* Maximum lookback window for the initial store query performed by
|
||||
* QueryOnConnect when a store peer connects.
|
||||
* @default [[MAX_TIME_RANGE_QUERY_MS]] (24 hours)
|
||||
*/
|
||||
maxTimeRangeQueryMs?: number;
|
||||
}
|
||||
|
||||
export enum QueryOnConnectEvent {
|
||||
@ -51,6 +57,7 @@ export class QueryOnConnect<
|
||||
private lastSuccessfulQuery: number;
|
||||
private lastTimeOffline: number;
|
||||
private readonly forceQueryThresholdMs: number;
|
||||
private readonly maxTimeRangeQueryMs: number;
|
||||
|
||||
public constructor(
|
||||
public decoders: IDecoder<T>[],
|
||||
@ -67,6 +74,8 @@ export class QueryOnConnect<
|
||||
this.lastTimeOffline = 0;
|
||||
this.forceQueryThresholdMs =
|
||||
options?.forceQueryThresholdMs ?? DEFAULT_FORCE_QUERY_THRESHOLD_MS;
|
||||
this.maxTimeRangeQueryMs =
|
||||
options?.maxTimeRangeQueryMs ?? MAX_TIME_RANGE_QUERY_MS;
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
@ -140,7 +149,7 @@ export class QueryOnConnect<
|
||||
return calculateTimeRange(
|
||||
Date.now(),
|
||||
this.lastSuccessfulQuery,
|
||||
MAX_TIME_RANGE_QUERY_MS
|
||||
this.maxTimeRangeQueryMs
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -111,6 +111,12 @@ export type ReliableChannelOptions = MessageChannelOptions & {
|
||||
* @default 1000 (1 second)
|
||||
*/
|
||||
processTaskMinElapseMs?: number;
|
||||
/**
|
||||
* Maximum lookback window for the initial store query performed by
|
||||
* QueryOnConnect when a store peer connects.
|
||||
* @default 24h
|
||||
*/
|
||||
initialQueryLookbackMs?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -190,7 +196,12 @@ export class ReliableChannel<
|
||||
[this.decoder],
|
||||
peerManagerEvents,
|
||||
node.events,
|
||||
this._retrieve.bind(this)
|
||||
this._retrieve.bind(this),
|
||||
{
|
||||
maxTimeRangeQueryMs: options?.initialQueryLookbackMs,
|
||||
// Keep existing default unless user overrides
|
||||
forceQueryThresholdMs: undefined
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user