mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
make pool.publish() return a single Pub object.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "1.6.3",
|
"version": "1.7.0",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
18
pool.ts
18
pool.ts
@@ -155,13 +155,23 @@ export class SimplePool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
publish(relays: string[], event: Event): Pub[] {
|
publish(relays: string[], event: Event): Pub {
|
||||||
return relays.map(relay => {
|
let pubs = relays.map(relay => {
|
||||||
let r = this._conn[normalizeURL(relay)]
|
let r = this._conn[normalizeURL(relay)]
|
||||||
if (!r) return badPub(relay)
|
if (!r) return badPub(relay)
|
||||||
let s = r.publish(event)
|
return r.publish(event)
|
||||||
return s
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
on(type, cb) {
|
||||||
|
pubs.forEach((pub, i) => {
|
||||||
|
pub.on(type, () => cb(relays[i]))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
off() {
|
||||||
|
// do nothing here, FIXME
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seenOn(id: string): string[] {
|
seenOn(id: string): string[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user