Add missing function
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Kieran 2023-07-06 00:08:17 +01:00
parent 4958611cca
commit 45a0ef4445
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 21 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system-react", "name": "@snort/system-react",
"version": "1.0.9", "version": "1.0.10",
"description": "React hooks for @snort/system", "description": "React hooks for @snort/system",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
@ -16,7 +16,7 @@
"dist" "dist"
], ],
"dependencies": { "dependencies": {
"@snort/system": "^1.0.14", "@snort/system": "^1.0.15",
"@snort/shared": "^1.0.4", "@snort/shared": "^1.0.4",
"react": "^18.2.0" "react": "^18.2.0"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system", "name": "@snort/system",
"version": "1.0.14", "version": "1.0.15",
"description": "Snort nostr system package", "description": "Snort nostr system package",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -4,7 +4,6 @@ import { unwrap, sanitizeRelayUrl, ExternalStore, FeedCache } from "@snort/share
import { NostrEvent, TaggedRawEvent } from "./nostr"; import { NostrEvent, TaggedRawEvent } from "./nostr";
import { AuthHandler, Connection, RelaySettings, ConnectionStateSnapshot } from "./connection"; import { AuthHandler, Connection, RelaySettings, ConnectionStateSnapshot } from "./connection";
import { Query } from "./query"; import { Query } from "./query";
import { RelayCache } from "./gossip-model";
import { NoteStore } from "./note-collection"; import { NoteStore } from "./note-collection";
import { BuiltRawReqFilter, RequestBuilder } from "./request-builder"; import { BuiltRawReqFilter, RequestBuilder } from "./request-builder";
import { RelayMetricHandler } from "./relay-metric-handler"; import { RelayMetricHandler } from "./relay-metric-handler";
@ -16,7 +15,9 @@ import {
SystemSnapshot, SystemSnapshot,
UserProfileCache, UserProfileCache,
UserRelaysCache, UserRelaysCache,
RelayMetricCache RelayMetricCache,
db,
UsersRelays
} from "."; } from ".";
/** /**
@ -43,7 +44,7 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
/** /**
* Storage class for user relay lists * Storage class for user relay lists
*/ */
#relayCache: RelayCache; #relayCache: FeedCache<UsersRelays>;
/** /**
* Storage class for user profiles * Storage class for user profiles
@ -67,7 +68,7 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
constructor(props: { constructor(props: {
authHandler?: AuthHandler, authHandler?: AuthHandler,
relayCache?: RelayCache, relayCache?: FeedCache<UsersRelays>,
profileCache?: FeedCache<MetadataCache> profileCache?: FeedCache<MetadataCache>
relayMetrics?: FeedCache<RelayMetrics> relayMetrics?: FeedCache<RelayMetrics>
}) { }) {
@ -93,6 +94,19 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
return [...this.#sockets.values()].map(a => a.snapshot()); return [...this.#sockets.values()].map(a => a.snapshot());
} }
/**
* Setup caches
*/
async Init() {
db.ready = await db.isAvailable();
const t = [
this.#relayCache.preload(),
this.#profileCache.preload(),
this.#relayMetricsCache.preload()
];
await Promise.all(t);
}
/** /**
* Connect to a NOSTR relay if not already connected * Connect to a NOSTR relay if not already connected
*/ */