Undo hack

pull/214/head
nielsandriesse 5 years ago
parent cba3d2d55b
commit f1ec7e67b1

@ -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 { if swarmCache[hexEncodedPublicKey] == nil {
storage.dbReadConnection.read { transaction in storage.dbReadConnection.read { transaction in
swarmCache[hexEncodedPublicKey] = storage.getSwarm(for: hexEncodedPublicKey, in: transaction) 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) } return Promise<[LokiAPITarget]> { $0.fulfill(cachedSwarm) }
} else { } else {
print("[Loki] Getting swarm for: \(hexEncodedPublicKey).") print("[Loki] Getting swarm for: \(hexEncodedPublicKey).")

@ -54,7 +54,7 @@ public final class LokiPoller : NSObject {
// MARK: Private API // MARK: Private API
private func setUpPolling() { private func setUpPolling() {
guard !hasStopped else { return } 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(()) } } guard let strongSelf = self else { return Promise { $0.fulfill(()) } }
strongSelf.usedSnodes.removeAll() strongSelf.usedSnodes.removeAll()
let (promise, seal) = Promise<Void>.pending() let (promise, seal) = Promise<Void>.pending()

@ -73,9 +73,6 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
return return
} }
self.add(jobRecord: jobRecord, transaction: transaction) 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 // MARK: JobQueue

Loading…
Cancel
Save