add optional idb "relay" worker

This commit is contained in:
Martti Malmi
2024-01-03 16:52:19 +02:00
parent 8571ea0aa7
commit 395848fd8c
12 changed files with 272 additions and 70 deletions

View File

@ -47,7 +47,10 @@ export default class SocialGraph {
}
}
handleFollowEvent(event: NostrEvent) {
handleEvent(event: NostrEvent) {
if (event.kind !== 3) {
return;
}
try {
const author = ID(event.pubkey);
const timestamp = event.created_at;

View File

@ -2,7 +2,7 @@ import debug from "debug";
import EventEmitter from "eventemitter3";
import { unwrap, FeedCache } from "@snort/shared";
import { NostrEvent, TaggedNostrEvent } from "./nostr";
import { NostrEvent, ReqFilter, TaggedNostrEvent } from "./nostr";
import { RelaySettings, ConnectionStateSnapshot, OkResponse } from "./connection";
import { Query } from "./query";
import { NoteCollection, NoteStore } from "./note-collection";
@ -31,6 +31,7 @@ export interface NostrSystemEvents {
change: (state: SystemSnapshot) => void;
auth: (challenge: string, relay: string, cb: (ev: NostrEvent) => void) => void;
event: (subId: string, ev: TaggedNostrEvent) => void;
request: (filter: ReqFilter) => void;
}
export interface NostrsystemProps {
@ -316,6 +317,10 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
}
qSend.filters = fNew;
fNew.forEach(f => {
this.emit("request", f);
});
if (qSend.relay) {
this.#log("Sending query to %s %O", qSend.relay, qSend);
const s = this.#pool.getConnection(qSend.relay);