mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Also drop guard snodes as needed
This commit is contained in:
parent
6aa360da71
commit
838688355b
|
@ -145,6 +145,10 @@ internal enum OnionRequestAPI {
|
|||
paths = paths.filter { !$0.contains(snode) }
|
||||
}
|
||||
|
||||
private static func dropGuardSnode(_ snode: LokiAPITarget) {
|
||||
guardSnodes = guardSnodes.filter { $0 != snode }
|
||||
}
|
||||
|
||||
/// Builds an onion around `payload` and returns the result.
|
||||
private static func buildOnion(around payload: JSON, targetedAt snode: LokiAPITarget) -> Promise<OnionBuildingResult> {
|
||||
var guardSnode: LokiAPITarget!
|
||||
|
@ -221,6 +225,7 @@ internal enum OnionRequestAPI {
|
|||
promise.catch(on: LokiAPI.workQueue) { error in // Must be invoked on LokiAPI.workQueue
|
||||
guard case HTTP.Error.httpRequestFailed(_, _) = error else { return }
|
||||
dropPath(containing: guardSnode) // A snode in the path is bad; retry with a different path
|
||||
dropGuardSnode(guardSnode)
|
||||
}
|
||||
promise.handlingErrorsIfNeeded(forTargetSnode: snode, associatedWith: hexEncodedPublicKey)
|
||||
return promise
|
||||
|
|
Loading…
Reference in a new issue