Undo hack

This commit is contained in:
nielsandriesse 2020-06-12 11:15:10 +10:00
parent cba3d2d55b
commit f1ec7e67b1
3 changed files with 3 additions and 6 deletions

View file

@ -114,13 +114,13 @@ public extension LokiAPI {
}
}
internal static func getSwarm(for hexEncodedPublicKey: String) -> Promise<[LokiAPITarget]> {
internal static func getSwarm(for hexEncodedPublicKey: String, isForcedReload: Bool = false) -> Promise<[LokiAPITarget]> {
if swarmCache[hexEncodedPublicKey] == nil {
storage.dbReadConnection.read { transaction in
swarmCache[hexEncodedPublicKey] = storage.getSwarm(for: hexEncodedPublicKey, in: transaction)
}
}
if let cachedSwarm = swarmCache[hexEncodedPublicKey], cachedSwarm.count >= minimumSwarmSnodeCount {
if let cachedSwarm = swarmCache[hexEncodedPublicKey], cachedSwarm.count >= minimumSwarmSnodeCount && !isForcedReload {
return Promise<[LokiAPITarget]> { $0.fulfill(cachedSwarm) }
} else {
print("[Loki] Getting swarm for: \(hexEncodedPublicKey).")

View file

@ -54,7 +54,7 @@ public final class LokiPoller : NSObject {
// MARK: Private API
private func setUpPolling() {
guard !hasStopped else { return }
LokiAPI.getSwarm(for: getUserHexEncodedPublicKey()).then2 { [weak self] _ -> Promise<Void> in
LokiAPI.getSwarm(for: getUserHexEncodedPublicKey(), isForcedReload: true).then2 { [weak self] _ -> Promise<Void> in
guard let strongSelf = self else { return Promise { $0.fulfill(()) } }
strongSelf.usedSnodes.removeAll()
let (promise, seal) = Promise<Void>.pending()

View file

@ -73,9 +73,6 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
return
}
self.add(jobRecord: jobRecord, transaction: transaction)
transaction.addCompletionQueue(DispatchQueue.global()) {
self.workStep() // Loki: Hack to make message sending faster until we have decentralized multi device and no more proof of work
}
}
// MARK: JobQueue