code clean-up: @discardableResult, unused params, simplify getting specific relays from pool
Closes: #635
This commit is contained in:
committed by
William Casarin
parent
a1a89dc98e
commit
193e922c9c
@@ -72,7 +72,7 @@ func char_to_hex(_ c: UInt8) -> UInt8?
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@discardableResult
|
||||
func hex_decode(_ str: String) -> [UInt8]?
|
||||
{
|
||||
if str.count == 0 {
|
||||
|
||||
@@ -195,27 +195,13 @@ class RelayPool {
|
||||
relay.connection.send(req)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func get_relays(_ ids: [String]) -> [Relay] {
|
||||
var relays: [Relay] = []
|
||||
|
||||
for id in ids {
|
||||
if let relay = get_relay(id) {
|
||||
relays.append(relay)
|
||||
}
|
||||
}
|
||||
|
||||
return relays
|
||||
relays.filter { ids.contains($0.id) }
|
||||
}
|
||||
|
||||
|
||||
func get_relay(_ id: String) -> Relay? {
|
||||
for relay in relays {
|
||||
if relay.id == id {
|
||||
return relay
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
relays.first(where: { $0.id == id })
|
||||
}
|
||||
|
||||
func record_last_pong(relay_id: String, event: NostrConnectionEvent) {
|
||||
|
||||
Reference in New Issue
Block a user