Use default pool, make adapter context optional
This commit is contained in:
@@ -2,13 +2,7 @@ import {hexToBytes} from "@noble/hashes/utils"
|
||||
import {getPublicKey, finalizeEvent} from "nostr-tools/pure"
|
||||
import {now} from "@welshman/lib"
|
||||
import {TrustedEvent, StampedEvent, Filter} from "@welshman/util"
|
||||
import {
|
||||
multireq,
|
||||
multicast,
|
||||
PublishEventType,
|
||||
RequestEventType,
|
||||
AdapterContext,
|
||||
} from "@welshman/net"
|
||||
import {multireq, multicast, PublishEvent, RequestEvent, AdapterContext} from "@welshman/net"
|
||||
|
||||
export type DVMHandler = {
|
||||
stop?: () => void
|
||||
@@ -20,10 +14,10 @@ export type CreateDVMHandler = (dvm: DVM) => DVMHandler
|
||||
export type DVMOpts = {
|
||||
sk: string
|
||||
relays: string[]
|
||||
context: AdapterContext
|
||||
handlers: Record<string, CreateDVMHandler>
|
||||
expireAfter?: number
|
||||
requireMention?: boolean
|
||||
context?: AdapterContext
|
||||
}
|
||||
|
||||
export class DVM {
|
||||
@@ -55,8 +49,8 @@ export class DVM {
|
||||
|
||||
const sub = multireq({relays, filter, context})
|
||||
|
||||
sub.on(RequestEventType.Event, (e: TrustedEvent, url: string) => this.onEvent(e))
|
||||
sub.on(RequestEventType.Close, () => resolve())
|
||||
sub.on(RequestEvent.Event, (e: TrustedEvent, url: string) => this.onEvent(e))
|
||||
sub.on(RequestEvent.Close, () => resolve())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -119,7 +113,7 @@ export class DVM {
|
||||
const event = finalizeEvent(template, hexToBytes(sk))
|
||||
|
||||
await new Promise<void>(resolve => {
|
||||
multicast({event, relays, context}).on(PublishEventType.Complete, resolve)
|
||||
multicast({event, relays, context}).on(PublishEvent.Complete, resolve)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user