Add extra params to outbox loaders, fix a message type, use net context's isEventValid in app repository sync
This commit is contained in:
@@ -26,9 +26,9 @@ export * from "./zappers.js"
|
|||||||
|
|
||||||
import {derived} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
import {sortBy, throttleWithValue, tryCatch} from "@welshman/lib"
|
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 {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 {pubkey} from "./session.js"
|
||||||
import {repository, tracker} from "./core.js"
|
import {repository, tracker} from "./core.js"
|
||||||
import {Relay, relays, loadRelay, trackRelayStats, getRelayQuality} from "./relays.js"
|
import {Relay, relays, loadRelay, trackRelayStats, getRelayQuality} from "./relays.js"
|
||||||
@@ -45,7 +45,11 @@ Pool.get().subscribe(socket => {
|
|||||||
if (isRelayEvent(message)) {
|
if (isRelayEvent(message)) {
|
||||||
const event = message[2]
|
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)
|
tracker.track(event.id, socket.url)
|
||||||
repository.publish(event)
|
repository.publish(event)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import {batcher} from "@welshman/lib"
|
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 {deriveEventsMapped, collection} from "@welshman/store"
|
||||||
import {load, LoadOptions} from "@welshman/net"
|
import {load, LoadOptions} from "@welshman/net"
|
||||||
import {Router} from "@welshman/router"
|
import {Router} from "@welshman/router"
|
||||||
@@ -14,15 +21,18 @@ export const loadUsingOutbox = batcher(200, (optionses: LoadUsingOutboxOptions[]
|
|||||||
return optionses.map(options => load({...options, relays}))
|
return optionses.map(options => load({...options, relays}))
|
||||||
})
|
})
|
||||||
|
|
||||||
export const makeOutboxLoader = (kind: number) => (pubkey: string, relays: string[]) => {
|
export const makeOutboxLoader =
|
||||||
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}), loadUsingOutbox({filters})])
|
return Promise.all([load({relays, filters}), loadUsingOutbox({filters})])
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeOutboxLoaderWithIndexers =
|
export const makeOutboxLoaderWithIndexers =
|
||||||
(kind: number) => (pubkey: string, relays: string[]) => {
|
(kind: number, filter: Filter = {}) =>
|
||||||
const filters = [{authors: [pubkey], kinds: [kind]}]
|
(pubkey: string, relays: string[]) => {
|
||||||
|
const filters = [{...filter, authors: [pubkey], kinds: [kind]}]
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
load({relays, filters}),
|
load({relays, filters}),
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ export class Thunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.controller.signal.addEventListener("abort", () => {
|
this.controller.signal.addEventListener("abort", () => {
|
||||||
console.log("abort")
|
|
||||||
for (const relay of options.relays) {
|
for (const relay of options.relays) {
|
||||||
this._setAborted(relay)
|
this._setAborted(relay)
|
||||||
}
|
}
|
||||||
@@ -228,8 +227,6 @@ export class MergedThunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.status)
|
|
||||||
|
|
||||||
this._notify()
|
this._notify()
|
||||||
|
|
||||||
if (thunks.every(thunkIsComplete)) {
|
if (thunks.every(thunkIsComplete)) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export type RelayAuthPayload = [string]
|
|||||||
|
|
||||||
export type RelayClosedPayload = [string, string]
|
export type RelayClosedPayload = [string, string]
|
||||||
|
|
||||||
export type RelayEosePayload = [string, SignedEvent]
|
export type RelayEosePayload = [string]
|
||||||
|
|
||||||
export type RelayEventPayload = [string, SignedEvent]
|
export type RelayEventPayload = [string, SignedEvent]
|
||||||
|
|
||||||
|
|||||||
Generated
-9
@@ -242,15 +242,6 @@ importers:
|
|||||||
specifier: ~5.8.0
|
specifier: ~5.8.0
|
||||||
version: 5.8.2
|
version: 5.8.2
|
||||||
|
|
||||||
packages/mls:
|
|
||||||
devDependencies:
|
|
||||||
rimraf:
|
|
||||||
specifier: ~6.0.0
|
|
||||||
version: 6.0.1
|
|
||||||
typescript:
|
|
||||||
specifier: ~5.8.0
|
|
||||||
version: 5.8.2
|
|
||||||
|
|
||||||
packages/net:
|
packages/net:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@welshman/lib':
|
'@welshman/lib':
|
||||||
|
|||||||
Reference in New Issue
Block a user