mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
pool: closed relays must be eliminated.
This commit is contained in:
@@ -50,6 +50,9 @@ export class AbstractSimplePool {
|
|||||||
verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
|
verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
|
||||||
websocketImplementation: this._WebSocket,
|
websocketImplementation: this._WebSocket,
|
||||||
})
|
})
|
||||||
|
relay.onclose = () => {
|
||||||
|
this.relays.delete(url)
|
||||||
|
}
|
||||||
if (params?.connectionTimeout) relay.connectionTimeout = params.connectionTimeout
|
if (params?.connectionTimeout) relay.connectionTimeout = params.connectionTimeout
|
||||||
this.relays.set(url, relay)
|
this.relays.set(url, relay)
|
||||||
}
|
}
|
||||||
@@ -61,6 +64,7 @@ export class AbstractSimplePool {
|
|||||||
close(relays: string[]) {
|
close(relays: string[]) {
|
||||||
relays.map(normalizeURL).forEach(url => {
|
relays.map(normalizeURL).forEach(url => {
|
||||||
this.relays.get(url)?.close()
|
this.relays.get(url)?.close()
|
||||||
|
this.relays.delete(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ export class AbstractRelay {
|
|||||||
this.closeAllSubscriptions('relay connection closed by us')
|
this.closeAllSubscriptions('relay connection closed by us')
|
||||||
this._connected = false
|
this._connected = false
|
||||||
this.ws?.close()
|
this.ws?.close()
|
||||||
|
this.onclose?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the function assigned to this.ws.onmessage
|
// this is the function assigned to this.ws.onmessage
|
||||||
|
|||||||
Reference in New Issue
Block a user