Fix issue that would cause RelayPool to close after ephemeral lease release
Issue was not released, so a changelog item is not needed. Changelog-None Closes: https://github.com/damus-io/damus/issues/3604 Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -414,12 +414,18 @@ class RelayPool {
|
|||||||
relay.connection.connect()
|
relay.connection.connect()
|
||||||
}
|
}
|
||||||
// Mark as open last, to prevent other classes from pulling data before the relays are actually connected
|
// Mark as open last, to prevent other classes from pulling data before the relays are actually connected
|
||||||
|
// Only mark as open when connecting ALL relays (not specific ones)
|
||||||
|
if targetRelays == nil {
|
||||||
open = true
|
open = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func disconnect(to targetRelays: [RelayURL]? = nil) async {
|
func disconnect(to targetRelays: [RelayURL]? = nil) async {
|
||||||
// Mark as closed first, to prevent other classes from pulling data while the relays are being disconnected
|
// Mark as closed first, to prevent other classes from pulling data while the relays are being disconnected
|
||||||
|
// Only mark as closed when disconnecting ALL relays (not specific ones)
|
||||||
|
if targetRelays == nil {
|
||||||
open = false
|
open = false
|
||||||
|
}
|
||||||
let relays = await getRelays(targetRelays: targetRelays)
|
let relays = await getRelays(targetRelays: targetRelays)
|
||||||
for relay in relays {
|
for relay in relays {
|
||||||
relay.connection.disconnect()
|
relay.connection.disconnect()
|
||||||
|
|||||||
Reference in New Issue
Block a user