Clean up nostr-tools dependencies

This commit is contained in:
Jon Staab
2025-04-01 10:50:43 -07:00
parent 04816f8377
commit 5ad6347123
10 changed files with 75 additions and 50 deletions
+16 -4
View File
@@ -1,14 +1,26 @@
import {throttle} from "@welshman/lib"
import {Repository, LocalRelay} from "@welshman/relay"
import {Tracker} from "@welshman/net"
import {verifyEvent, isEphemeralKind, isDVMKind} from "@welshman/util"
import {Repository} from "@welshman/relay"
import {Pool, Tracker, SocketEvent, isRelayEvent} from "@welshman/net"
import {custom} from "@welshman/store"
export const repository = Repository.getSingleton()
export const relay = new LocalRelay(repository)
export const tracker = new Tracker()
Pool.getSingleton().subscribe(socket => {
socket.on(SocketEvent.Receive, message => {
if (isRelayEvent(message)) {
const event = message[2]
if (!isEphemeralKind(event.kind) && !isDVMKind(event.kind) && verifyEvent(event)) {
tracker.track(event.id, socket.url)
repository.publish(event)
}
}
})
})
// Adapt above objects to stores
export const makeRepositoryStore = ({throttle: t = 300}: {throttle?: number} = {}) =>