damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 1fe54380b898cf487926932cc9a18fc6282d1ae4
parent fe6d7e5118fb76ffd866ed589340c97a9880faed
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 10 May 2023 13:24:46 -0700

relay: make RelayInfo encoding more flexible

So that we don't fail relay list decoding as easy

Diffstat:
Mdamus/Nostr/Relay.swift | 6+++---
Mdamus/Nostr/RelayPool.swift | 8++++----
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/damus/Nostr/Relay.swift b/damus/Nostr/Relay.swift @@ -8,9 +8,9 @@ import Foundation public struct RelayInfo: Codable { - let read: Bool - let write: Bool - let ephemeral: Bool + let read: Bool? + let write: Bool? + let ephemeral: Bool? init(read: Bool, write: Bool, ephemeral: Bool = false) { self.read = read diff --git a/damus/Nostr/RelayPool.swift b/damus/Nostr/RelayPool.swift @@ -43,7 +43,7 @@ class RelayPool { } var our_descriptors: [RelayDescriptor] { - return all_descriptors.filter { d in !d.info.ephemeral } + return all_descriptors.filter { d in !(d.info.ephemeral ?? false) } } var all_descriptors: [RelayDescriptor] { @@ -188,15 +188,15 @@ class RelayPool { let relays = to.map{ get_relays($0) } ?? self.relays for relay in relays { - if req.is_read && !relay.descriptor.info.read { + if req.is_read && !(relay.descriptor.info.read ?? true) { continue } - if req.is_write && !relay.descriptor.info.write { + if req.is_write && !(relay.descriptor.info.write ?? true) { continue } - if relay.descriptor.info.ephemeral && skip_ephemeral { + if (relay.descriptor.info.ephemeral ?? false) && skip_ephemeral { continue }