mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
turn .publish() into a normal async function returning a promise.
this simplifies the code and makes the API more intuitive. we used to need the event emitter thing because we were subscribing to the same relay to check if the event had been published, but that is not necessary now that we assume an OK response will always come. closes https://github.com/nbd-wtf/nostr-tools/issues/262
This commit is contained in:
@@ -108,13 +108,7 @@ let event = {
|
||||
event.id = getEventHash(event)
|
||||
event.sig = getSignature(event, sk)
|
||||
|
||||
let pub = relay.publish(event)
|
||||
pub.on('ok', () => {
|
||||
console.log(`${relay.url} has accepted our event`)
|
||||
})
|
||||
pub.on('failed', reason => {
|
||||
console.log(`failed to publish to ${relay.url}: ${reason}`)
|
||||
})
|
||||
await relay.publish(event)
|
||||
|
||||
let events = await relay.list([{kinds: [0, 1]}])
|
||||
let event = await relay.get({
|
||||
|
||||
Reference in New Issue
Block a user