Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit f0320ae

Browse files
authored
Merge pull request #137 from synonymdev/scorer-remove
iOS remove cached scorer
2 parents c11744a + c947e93 commit f0320ae

2 files changed

Lines changed: 35 additions & 30 deletions

File tree

lib/ios/Classes/LdkChannelManagerPersister.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,19 @@ class LdkChannelManagerPersister: Persister, ExtendedChannelManagerPersister {
244244
}
245245

246246
override func persistScorer(scorer: WriteableScore) -> Bindings.Result_NoneErrorZ {
247-
guard let scorerStorage = Ldk.accountStoragePath?.appendingPathComponent(LdkFileNames.scorer.rawValue) else {
248-
return Result_NoneErrorZ.initWithErr(e: .Other)
249-
}
250-
251-
do {
252-
try Data(scorer.write()).write(to: scorerStorage)
253-
254-
return Result_NoneErrorZ.initWithOk()
255-
} catch {
256-
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist scorer to disk Error \(error.localizedDescription).")
257-
return Result_NoneErrorZ.initWithErr(e: .Other)
258-
}
247+
return Result_NoneErrorZ.initWithOk()
248+
249+
// guard let scorerStorage = Ldk.accountStoragePath?.appendingPathComponent(LdkFileNames.scorer.rawValue) else {
250+
// return Result_NoneErrorZ.initWithErr(e: .Other)
251+
// }
252+
//
253+
// do {
254+
// try Data(scorer.write()).write(to: scorerStorage)
255+
//
256+
// return Result_NoneErrorZ.initWithOk()
257+
// } catch {
258+
// LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist scorer to disk Error \(error.localizedDescription).")
259+
// return Result_NoneErrorZ.initWithErr(e: .Other)
260+
// }
259261
}
260262
}

lib/ios/Helpers.swift

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,28 @@ func currencyString(_ currency: Currency) -> String {
5252
func getProbabilisticScorer(path: URL, networkGraph: NetworkGraph, logger: LdkLogger) -> ProbabilisticScorer {
5353
let scoringParams = ProbabilisticScoringParameters.initWithDefault()
5454

55-
var probabalisticScorer: ProbabilisticScorer?
56-
if let storedScorer = try? Data(contentsOf: path.appendingPathComponent(LdkFileNames.scorer.rawValue).standardizedFileURL) {
57-
let scorerRead = ProbabilisticScorer.read(ser: [UInt8](storedScorer), argA: scoringParams, argB: networkGraph, argC: logger)
58-
59-
if scorerRead.isOk() {
60-
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Loaded scorer from disk")
61-
probabalisticScorer = scorerRead.getValue()
62-
} else {
63-
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Failed to load cached scorer")
64-
}
65-
}
66-
67-
//Doesn't exist or error reading it
68-
if probabalisticScorer == nil {
69-
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Starting scorer from scratch")
70-
probabalisticScorer = ProbabilisticScorer(params: scoringParams, networkGraph: networkGraph, logger: logger)
71-
}
55+
//TODO remove below line and uncomment below to enable reading cached scorer again
56+
return ProbabilisticScorer(params: scoringParams, networkGraph: networkGraph, logger: logger)
7257

73-
return probabalisticScorer!
58+
// var probabalisticScorer: ProbabilisticScorer?
59+
// if let storedScorer = try? Data(contentsOf: path.appendingPathComponent(LdkFileNames.scorer.rawValue).standardizedFileURL) {
60+
// let scorerRead = ProbabilisticScorer.read(ser: [UInt8](storedScorer), argA: scoringParams, argB: networkGraph, argC: logger)
61+
//
62+
// if scorerRead.isOk() {
63+
// LdkEventEmitter.shared.send(withEvent: .native_log, body: "Loaded scorer from disk")
64+
// probabalisticScorer = scorerRead.getValue()
65+
// } else {
66+
// LdkEventEmitter.shared.send(withEvent: .native_log, body: "Failed to load cached scorer")
67+
// }
68+
// }
69+
//
70+
// //Doesn't exist or error reading it
71+
// if probabalisticScorer == nil {
72+
// LdkEventEmitter.shared.send(withEvent: .native_log, body: "Starting scorer from scratch")
73+
// probabalisticScorer = ProbabilisticScorer(params: scoringParams, networkGraph: networkGraph, logger: logger)
74+
// }
75+
//
76+
// return probabalisticScorer!
7477
}
7578

7679
extension Invoice {

0 commit comments

Comments
 (0)