Skip to content

Commit 6e7c631

Browse files
committed
fix: esplora percent progress
1 parent 6673a1a commit 6e7c631

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

BDKSwiftExampleWallet/View Model/WalletViewModel.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,16 @@ class WalletViewModel {
5151
private var updateProgress: @Sendable (UInt64, UInt64) -> Void {
5252
{ [weak self] inspected, total in
5353
DispatchQueue.main.async {
54+
// When using Kyoto, progress is provided separately as percent
55+
if self?.isKyotoClient == true { return }
5456
self?.totalScripts = total
5557
self?.inspectedScripts = inspected
56-
self?.progress = total > 0 ? Float(inspected) / Float(total) : 0
58+
let fraction = total > 0 ? Float(inspected) / Float(total) : 0
59+
self?.progress = fraction
60+
#if DEBUG
61+
let percent = Int((fraction * 100).rounded())
62+
print("[Esplora][VM] inspected=\(inspected)/\(total) fraction=\(String(format: "%.4f", fraction)) percent=\(percent)%")
63+
#endif
5764
}
5865
}
5966
}
@@ -65,6 +72,9 @@ class WalletViewModel {
6572
let progressPercent = UInt64(progress)
6673
self?.inspectedScripts = progressPercent
6774
self?.totalScripts = 100
75+
#if DEBUG
76+
print("[Kyoto][VM] percent=\(Int(progress))%")
77+
#endif
6878
}
6979
}
7080
}

BDKSwiftExampleWallet/View/Home/ActivityHomeHeaderView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ struct ActivityHomeHeaderView: View {
7171
}
7272

7373
if !isKyotoClient || (isKyotoClient && progress > 0) {
74+
let percent: Int = isKyotoClient
75+
? Int(progress.rounded())
76+
: Int((progress * 100).rounded())
7477
HStack(spacing: 0) {
75-
Text("\(Int(progress))")
78+
Text("\(percent)")
7679
.contentTransition(.numericText())
7780
Text("%")
7881
}

0 commit comments

Comments
 (0)