mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-02 13:53:12 +00:00
chore: interface abstractions
This commit is contained in:
parent
959cad9a4d
commit
b437e19d3c
@ -48,6 +48,11 @@ export interface ILocalHistory {
|
||||
): number;
|
||||
}
|
||||
|
||||
export interface MemLocalHistoryOptions {
|
||||
storage?: ChannelId | PersistentStorage;
|
||||
maxSize?: number;
|
||||
}
|
||||
|
||||
export class MemLocalHistory implements ILocalHistory {
|
||||
private items: ContentMessage[] = [];
|
||||
private readonly storage?: PersistentStorage;
|
||||
@ -60,9 +65,7 @@ export class MemLocalHistory implements ILocalHistory {
|
||||
* - storage: Optional persistent storage backend for message persistence or channelId to use with PersistentStorage.
|
||||
* - maxSize: The maximum number of messages to store. Optional, defaults to DEFAULT_MAX_LENGTH.
|
||||
*/
|
||||
public constructor(
|
||||
opts: { storage?: ChannelId | PersistentStorage; maxSize?: number } = {}
|
||||
) {
|
||||
public constructor(opts: MemLocalHistoryOptions = {}) {
|
||||
const { storage, maxSize } = opts;
|
||||
this.maxSize = maxSize ?? DEFAULT_MAX_LENGTH;
|
||||
if (storage instanceof PersistentStorage) {
|
||||
|
||||
@ -15,7 +15,8 @@ import {
|
||||
} from "./message.js";
|
||||
import {
|
||||
DEFAULT_BLOOM_FILTER_OPTIONS,
|
||||
MessageChannel
|
||||
MessageChannel,
|
||||
MessageChannelOptions
|
||||
} from "./message_channel.js";
|
||||
|
||||
const channelId = "test-channel";
|
||||
@ -30,12 +31,7 @@ const callback = (_message: Message): Promise<{ success: boolean }> => {
|
||||
const createTestChannel = (
|
||||
channelId: string,
|
||||
senderId: string,
|
||||
options: {
|
||||
causalHistorySize?: number;
|
||||
possibleAcksThreshold?: number;
|
||||
timeoutForLostMessagesMs?: number;
|
||||
enableRepair?: boolean;
|
||||
} = {}
|
||||
options: MessageChannelOptions = {}
|
||||
): MessageChannel => {
|
||||
return new MessageChannel(
|
||||
channelId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user