chore: move sqlite files

fix: debug print for deletes
This commit is contained in:
2024-06-05 15:33:11 +01:00
parent b2b25377cd
commit ebc45ae9c1
9 changed files with 35 additions and 22 deletions

View File

@ -1,16 +1,16 @@
import { Connection, SyncCommand } from "../connection";
import { FallbackSyncMethod } from "../system";
import { EventExt, EventType } from "../event-ext";
import { NoteCollection } from "../note-collection";
import { RangeSync } from "./range-sync";
import { NegentropyFlow } from "../negentropy/negentropy-flow";
import { SystemConfig } from "../system";
export interface ConnectionSyncModule {
sync: (c: Connection, item: SyncCommand, cb?: () => void) => void;
}
export class DefaultSyncModule implements ConnectionSyncModule {
constructor(readonly method: FallbackSyncMethod) {}
constructor(readonly method: SystemConfig["fallbackSync"]) {}
sync(c: Connection, item: SyncCommand, cb?: () => void) {
const [_, id, eventSet, ...filters] = item;
@ -49,9 +49,9 @@ export class DefaultSyncModule implements ConnectionSyncModule {
);
if (filters.some(a => a.since || a.until || a.ids || a.limit) || isReplaceableSync) {
c.request(["REQ", id, ...filters], cb);
} else if (this.method === FallbackSyncMethod.Since) {
} else if (this.method === "since") {
this.#syncSince(c, item, cb);
} else if (this.method === FallbackSyncMethod.RangeSync) {
} else if (this.method === "range-sync") {
this.#syncRangeSync(c, item, cb);
} else {
throw new Error("No fallback sync method");

View File

@ -5,7 +5,7 @@ import { EventsCache } from "./cache/events";
import { UserFollowsCache } from "./cache/user-follows-lists";
import { UserRelaysCache, UserProfileCache, RelayMetricCache, NostrEvent } from "./index";
import { DefaultOptimizer, Optimizer } from "./query-optimizer";
import { FallbackSyncMethod, NostrSystemEvents, SystemConfig } from "./system";
import { NostrSystemEvents, SystemConfig } from "./system";
import { EventEmitter } from "eventemitter3";
export abstract class SystemBase extends EventEmitter<NostrSystemEvents> {
@ -30,7 +30,7 @@ export abstract class SystemBase extends EventEmitter<NostrSystemEvents> {
db: props.db,
automaticOutboxModel: props.automaticOutboxModel ?? true,
buildFollowGraph: props.buildFollowGraph ?? false,
fallbackSync: props.fallbackSync ?? FallbackSyncMethod.Since,
fallbackSync: props.fallbackSync ?? "since",
};
}

View File

@ -95,12 +95,7 @@ export interface SystemConfig {
/**
* Pick a fallback sync method when negentropy is not available
*/
fallbackSync: FallbackSyncMethod;
}
export enum FallbackSyncMethod {
Since = "since",
RangeSync = "range-sync",
fallbackSync: "since" | "range-sync";
}
export interface SystemInterface {