refactor: preload with follow list

This commit is contained in:
2024-02-22 11:46:53 +00:00
parent 670898c016
commit 5e1af603b7
7 changed files with 18 additions and 17 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@snort/system",
"version": "1.2.10",
"version": "1.2.11",
"description": "Snort nostr system package",
"type": "module",
"main": "dist/index.js",
@ -36,7 +36,7 @@
"@noble/curves": "^1.2.0",
"@noble/hashes": "^1.3.2",
"@scure/base": "^1.1.2",
"@snort/shared": "^1.0.13",
"@snort/shared": "^1.0.14",
"@stablelib/xchacha20": "^1.0.1",
"debug": "^4.3.4",
"eventemitter3": "^5.0.1",

View File

@ -68,8 +68,9 @@ export interface SystemInterface {
/**
* Do some initialization
* @param follows A follower list to preload content for
*/
Init(): Promise<void>;
Init(follows?: Array<string>): Promise<void>;
/**
* Get an active query by ID

View File

@ -269,13 +269,13 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
this.#queryManager.on("request", (subId: string, f: BuiltRawReqFilter) => this.emit("request", subId, f));
}
async Init() {
async Init(follows?: Array<string>) {
const t = [
this.relayCache.preload(),
this.profileCache.preload(),
this.relayMetricsCache.preload(),
this.eventsCache.preload(),
this.userFollowsCache.preload(),
this.relayCache.preload(follows),
this.profileCache.preload(follows),
this.relayMetricsCache.preload(follows),
this.eventsCache.preload(follows),
this.userFollowsCache.preload(follows),
];
await Promise.all(t);
await this.PreloadSocialGraph();