@@ -39,6 +39,24 @@ class WalletViewModel {
3939 var transactions : [ CanonicalTx ]
4040 var walletSyncState : WalletSyncState
4141 var walletViewError : AppError ?
42+
43+ private var updateProgress : @Sendable ( UInt64 , UInt64 ) -> Void {
44+ { [ weak self] inspected, total in
45+ DispatchQueue . main. async {
46+ self ? . totalScripts = total
47+ self ? . inspectedScripts = inspected
48+ self ? . progress = total > 0 ? Float ( inspected) / Float( total) : 0
49+ }
50+ }
51+ }
52+
53+ private var updateProgressFullScan : @Sendable ( UInt64 ) -> Void {
54+ { [ weak self] inspected in
55+ DispatchQueue . main. async {
56+ self ? . inspectedScripts = inspected
57+ }
58+ }
59+ }
4260
4361 init (
4462 bdkClient: BDKClient = . live,
@@ -144,29 +162,14 @@ class WalletViewModel {
144162 await startSyncWithProgress ( )
145163 }
146164 }
147-
148- private func updateProgress( inspected: UInt64 , total: UInt64 ) {
149- DispatchQueue . main. async {
150- self . totalScripts = total
151- self . inspectedScripts = inspected
152- self . progress = total > 0 ? Float ( inspected) / Float( total) : 0
153- }
154- }
155-
156- private func updateProgressFullScan( inspected: UInt64 ) {
157- DispatchQueue . main. async {
158- self . inspectedScripts = inspected
159- }
160- }
161-
162165}
163166
164- class WalletSyncScriptInspector : SyncScriptInspector {
165- private let updateProgress : ( UInt64 , UInt64 ) -> Void
167+ actor WalletSyncScriptInspector : @ preconcurrency SyncScriptInspector {
168+ private let updateProgress : @ Sendable ( UInt64 , UInt64 ) -> Void
166169 private var inspectedCount : UInt64 = 0
167170 private var totalCount : UInt64 = 0
168171
169- init ( updateProgress: @escaping ( UInt64 , UInt64 ) -> Void ) {
172+ init ( updateProgress: @escaping @ Sendable ( UInt64 , UInt64 ) -> Void ) {
170173 self . updateProgress = updateProgress
171174 }
172175
@@ -189,11 +192,11 @@ class WalletSyncScriptInspector: SyncScriptInspector {
189192 }
190193}
191194
192- class WalletFullScanScriptInspector : FullScanScriptInspector {
193- private let updateProgress : ( UInt64 ) -> Void
195+ actor WalletFullScanScriptInspector : @ preconcurrency FullScanScriptInspector {
196+ private let updateProgress : @ Sendable ( UInt64 ) -> Void
194197 private var inspectedCount : UInt64 = 0
195198
196- init ( updateProgress: @escaping ( UInt64 ) -> Void ) {
199+ init ( updateProgress: @escaping @ Sendable ( UInt64 ) -> Void ) {
197200 self . updateProgress = updateProgress
198201 }
199202
0 commit comments