Recommended relay view
Changelog-Changed: Show recommended relays in config. Currently just a fixed set.
This commit is contained in:
@@ -144,6 +144,7 @@ func remove_relay(ev: NostrEvent, current_relays: [RelayDescriptor], privkey: St
|
||||
|
||||
relays.removeValue(forKey: relay)
|
||||
|
||||
print("remove_relay \(relays)")
|
||||
guard let content = encode_json(relays) else {
|
||||
return nil
|
||||
}
|
||||
@@ -154,10 +155,9 @@ func remove_relay(ev: NostrEvent, current_relays: [RelayDescriptor], privkey: St
|
||||
return new_ev
|
||||
}
|
||||
|
||||
func add_relay(ev: NostrEvent, privkey: String, relay: String, info: RelayInfo) -> NostrEvent? {
|
||||
let damus_relay = RelayDescriptor(url: URL(string: "wss://relay.damus.io")!, info: .rw)
|
||||
func add_relay(ev: NostrEvent, privkey: String, current_relays: [RelayDescriptor], relay: String, info: RelayInfo) -> NostrEvent? {
|
||||
var relays = ensure_relay_info(relays: current_relays, content: ev.content)
|
||||
|
||||
var relays = ensure_relay_info(relays: [damus_relay], content: ev.content)
|
||||
guard relays.index(forKey: relay) == nil else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -623,26 +623,3 @@ func load_our_relays(contacts: Contacts, our_pubkey: String, pool: RelayPool, m_
|
||||
}
|
||||
|
||||
|
||||
func remove_bootstrap_nodes(_ damus_state: DamusState) {
|
||||
guard let contacts = damus_state.contacts.event else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let relays = decode_json_relays(contacts.content) else {
|
||||
return
|
||||
}
|
||||
|
||||
let descriptors = relays.reduce(into: []) { arr, kv in
|
||||
guard let url = URL(string: kv.key) else {
|
||||
return
|
||||
}
|
||||
arr.append(RelayDescriptor(url: url, info: kv.value))
|
||||
}
|
||||
|
||||
for relay in BOOTSTRAP_RELAYS {
|
||||
if !(descriptors.contains { ($0 as! RelayDescriptor).url.absoluteString == relay }) {
|
||||
damus_state.pool.remove_relay(relay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user