Guard against snodes requesting incorrect proof of work

This commit is contained in:
nielsandriesse 2020-06-19 11:21:02 +10:00
parent 6b19b2180b
commit 6aacbff908

View file

@ -93,7 +93,7 @@ public final class LokiAPI : NSObject {
invoke(.sendMessage, on: snode, associatedWith: destination, parameters: parameters)
}.map2 { rawResponse in
if let json = rawResponse as? JSON, let powDifficulty = json["difficulty"] as? Int {
guard powDifficulty != LokiAPI.powDifficulty else { return rawResponse }
guard powDifficulty != LokiAPI.powDifficulty, powDifficulty < 100 else { return rawResponse }
print("[Loki] Setting proof of work difficulty to \(powDifficulty).")
LokiAPI.powDifficulty = UInt(powDifficulty)
} else {