Add extra params to outbox loaders, fix a message type, use net context's isEventValid in app repository sync

This commit is contained in:
Jon Staab
2025-09-02 15:47:48 -07:00
parent cfb126cca4
commit f009801c84
5 changed files with 25 additions and 23 deletions
+7 -3
View File
@@ -26,9 +26,9 @@ export * from "./zappers.js"
import {derived} from "svelte/store"
import {sortBy, throttleWithValue, tryCatch} from "@welshman/lib"
import {verifyEvent, isEphemeralKind, isDVMKind, RelayMode, getRelaysFromList} from "@welshman/util"
import {isEphemeralKind, isDVMKind, RelayMode, getRelaysFromList} from "@welshman/util"
import {routerContext} from "@welshman/router"
import {Pool, SocketEvent, isRelayEvent} from "@welshman/net"
import {Pool, SocketEvent, isRelayEvent, netContext} from "@welshman/net"
import {pubkey} from "./session.js"
import {repository, tracker} from "./core.js"
import {Relay, relays, loadRelay, trackRelayStats, getRelayQuality} from "./relays.js"
@@ -45,7 +45,11 @@ Pool.get().subscribe(socket => {
if (isRelayEvent(message)) {
const event = message[2]
if (!isEphemeralKind(event.kind) && !isDVMKind(event.kind) && verifyEvent(event)) {
if (
!isEphemeralKind(event.kind) &&
!isDVMKind(event.kind) &&
netContext.isEventValid(event, socket.url)
) {
tracker.track(event.id, socket.url)
repository.publish(event)
}
+17 -7
View File
@@ -1,5 +1,12 @@
import {batcher} from "@welshman/lib"
import {RELAYS, asDecryptedEvent, readList, TrustedEvent, PublishedList} from "@welshman/util"
import {
RELAYS,
Filter,
asDecryptedEvent,
readList,
TrustedEvent,
PublishedList,
} from "@welshman/util"
import {deriveEventsMapped, collection} from "@welshman/store"
import {load, LoadOptions} from "@welshman/net"
import {Router} from "@welshman/router"
@@ -14,15 +21,18 @@ export const loadUsingOutbox = batcher(200, (optionses: LoadUsingOutboxOptions[]
return optionses.map(options => load({...options, relays}))
})
export const makeOutboxLoader = (kind: number) => (pubkey: string, relays: string[]) => {
const filters = [{authors: [pubkey], kinds: [kind]}]
export const makeOutboxLoader =
(kind: number, filter: Filter = {}) =>
(pubkey: string, relays: string[]) => {
const filters = [{...filter, authors: [pubkey], kinds: [kind]}]
return Promise.all([load({relays, filters}), loadUsingOutbox({filters})])
}
return Promise.all([load({relays, filters}), loadUsingOutbox({filters})])
}
export const makeOutboxLoaderWithIndexers =
(kind: number) => (pubkey: string, relays: string[]) => {
const filters = [{authors: [pubkey], kinds: [kind]}]
(kind: number, filter: Filter = {}) =>
(pubkey: string, relays: string[]) => {
const filters = [{...filter, authors: [pubkey], kinds: [kind]}]
return Promise.all([
load({relays, filters}),
-3
View File
@@ -69,7 +69,6 @@ export class Thunk {
}
this.controller.signal.addEventListener("abort", () => {
console.log("abort")
for (const relay of options.relays) {
this._setAborted(relay)
}
@@ -228,8 +227,6 @@ export class MergedThunk {
}
}
console.log(this.status)
this._notify()
if (thunks.every(thunkIsComplete)) {