Get around CCP bootstrap relay banning by caching user's relays as their bootstrap relays

Changelog-Fixed: Get around CCP bootstrap relay banning by caching user's relays as their bootstrap relays
This commit is contained in:
William Casarin
2023-04-04 10:12:29 -07:00
parent 3da12e708f
commit 679779ab3e
9 changed files with 73 additions and 17 deletions

View File

@@ -743,7 +743,7 @@ func process_contact_event(state: DamusState, ev: NostrEvent) {
func load_our_relays(state: DamusState, m_old_ev: NostrEvent?, ev: NostrEvent) {
let bootstrap_dict: [String: RelayInfo] = [:]
let old_decoded = m_old_ev.flatMap { decode_json_relays($0.content) } ?? BOOTSTRAP_RELAYS.reduce(into: bootstrap_dict) { (d, r) in
let old_decoded = m_old_ev.flatMap { decode_json_relays($0.content) } ?? state.bootstrap_relays.reduce(into: bootstrap_dict) { (d, r) in
d[r] = .rw
}
@@ -778,6 +778,7 @@ func load_our_relays(state: DamusState, m_old_ev: NostrEvent?, ev: NostrEvent) {
}
if changed {
save_bootstrap_relays(pubkey: state.pubkey, relays: Array(new))
notify(.relays_changed, ())
}
}