Also drop guard snodes as needed

This commit is contained in:
nielsandriesse 2020-04-14 09:55:43 +10:00
parent 6aa360da71
commit 838688355b

View file

@ -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