mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 16:48:50 +00:00
EOSE nip-15
This commit is contained in:
7
pool.js
7
pool.js
@@ -26,7 +26,7 @@ export function relayPool() {
|
||||
|
||||
const activeSubscriptions = {}
|
||||
|
||||
const sub = ({cb, filter, beforeSend}, id) => {
|
||||
const sub = ({cb, filter, beforeSend}, id, cbEose) => {
|
||||
if (!id) id = Math.random().toString().slice(2)
|
||||
|
||||
const subControllers = Object.fromEntries(
|
||||
@@ -34,7 +34,8 @@ export function relayPool() {
|
||||
.filter(({policy}) => policy.read)
|
||||
.map(({relay}) => [
|
||||
relay.url,
|
||||
relay.sub({cb: event => cb(event, relay.url), filter, beforeSend}, id)
|
||||
relay.sub({cb: event => cb(event, relay.url), filter, beforeSend}, id,
|
||||
cbEose)
|
||||
])
|
||||
)
|
||||
|
||||
@@ -60,7 +61,7 @@ export function relayPool() {
|
||||
const addRelay = relay => {
|
||||
subControllers[relay.url] = relay.sub(
|
||||
{cb: event => cb(event, relay.url), filter, beforeSend},
|
||||
id
|
||||
id, () => cbEose(relay.url)
|
||||
)
|
||||
return activeSubscriptions[id]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user