mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-07 16:23:09 +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]]
|
* @default [[DEFAULT_FORCE_QUERY_THRESHOLD_MS]]
|
||||||
*/
|
*/
|
||||||
forceQueryThresholdMs?: number;
|
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 {
|
export enum QueryOnConnectEvent {
|
||||||
@ -51,6 +57,7 @@ export class QueryOnConnect<
|
|||||||
private lastSuccessfulQuery: number;
|
private lastSuccessfulQuery: number;
|
||||||
private lastTimeOffline: number;
|
private lastTimeOffline: number;
|
||||||
private readonly forceQueryThresholdMs: number;
|
private readonly forceQueryThresholdMs: number;
|
||||||
|
private readonly maxTimeRangeQueryMs: number;
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
public decoders: IDecoder<T>[],
|
public decoders: IDecoder<T>[],
|
||||||
@ -67,6 +74,8 @@ export class QueryOnConnect<
|
|||||||
this.lastTimeOffline = 0;
|
this.lastTimeOffline = 0;
|
||||||
this.forceQueryThresholdMs =
|
this.forceQueryThresholdMs =
|
||||||
options?.forceQueryThresholdMs ?? DEFAULT_FORCE_QUERY_THRESHOLD_MS;
|
options?.forceQueryThresholdMs ?? DEFAULT_FORCE_QUERY_THRESHOLD_MS;
|
||||||
|
this.maxTimeRangeQueryMs =
|
||||||
|
options?.maxTimeRangeQueryMs ?? MAX_TIME_RANGE_QUERY_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(): void {
|
public start(): void {
|
||||||
@ -140,7 +149,7 @@ export class QueryOnConnect<
|
|||||||
return calculateTimeRange(
|
return calculateTimeRange(
|
||||||
Date.now(),
|
Date.now(),
|
||||||
this.lastSuccessfulQuery,
|
this.lastSuccessfulQuery,
|
||||||
MAX_TIME_RANGE_QUERY_MS
|
this.maxTimeRangeQueryMs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -111,6 +111,12 @@ export type ReliableChannelOptions = MessageChannelOptions & {
|
|||||||
* @default 1000 (1 second)
|
* @default 1000 (1 second)
|
||||||
*/
|
*/
|
||||||
processTaskMinElapseMs?: number;
|
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],
|
[this.decoder],
|
||||||
peerManagerEvents,
|
peerManagerEvents,
|
||||||
node.events,
|
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