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:
Daniel D’Aquino
2026-02-04 19:17:47 -08:00
parent 8c5027248b
commit e271fa90d9

View File

@@ -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
open = true // Only mark as open when connecting ALL relays (not specific ones)
if targetRelays == nil {
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
open = false // Only mark as closed when disconnecting ALL relays (not specific ones)
if targetRelays == nil {
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()