@@ -132,7 +132,7 @@ final class KyotoService: BDKSyncService {
132
132
133
133
private func startNode( ) async throws {
134
134
node? . run ( )
135
- printLogs ( )
135
+ getNextLog ( )
136
136
updateWarn ( )
137
137
try await updateWallet ( )
138
138
startRealTimeWalletUpdate ( )
@@ -142,44 +142,42 @@ final class KyotoService: BDKSyncService {
142
142
private func updateWallet( ) async throws -> Bool {
143
143
guard let update = await self . client? . update ( ) else {
144
144
isScanRunning = false
145
- print ( " Nothing to update " )
146
145
return false
147
146
}
148
147
try self . wallet? . applyUpdate ( update: update)
149
148
let _ = try self . wallet? . persist ( connection: self . connection ?? Connection . loadConnection ( ) )
150
- print ( " ######### walletUpdated " )
151
149
isScanRunning = false
152
150
return true
153
151
}
154
152
155
153
private func startRealTimeWalletUpdate( ) {
156
- print ( #function)
157
154
Task {
158
155
while true {
159
- print ( " Updating: \( Date ( ) ) " )
160
- if let update = await client? . update ( ) {
161
- do {
162
- try wallet? . applyUpdate ( update: update)
156
+ do {
157
+ if try await updateWallet ( ) {
163
158
NotificationCenter . default. post ( name: . walletDidUpdate, object: nil )
164
- print ( " Updated wallet " )
165
- } catch {
166
- print ( error)
167
159
}
168
- } else {
169
- print ( " Nothing to update " )
160
+ } catch {
161
+ print ( error )
170
162
}
163
+ // if let update = await client?.update() {
164
+ // do {
165
+ // try wallet?.applyUpdate(update: update)
166
+ // NotificationCenter.default.post(name: .walletDidUpdate, object: nil)
167
+ // } catch {
168
+ // print(error)
169
+ // }
170
+ // }
171
171
}
172
172
}
173
173
}
174
174
175
- private func printLogs ( ) {
175
+ private func getNextLog ( ) {
176
176
Task {
177
177
while true {
178
178
if let log = try ? await self . client? . nextLog ( ) {
179
- print ( " \( log) " )
180
179
switch log {
181
180
case . connectionsMet:
182
- print ( " ######### connected " )
183
181
self . isConnected = true
184
182
case . progress( let progress) :
185
183
if let fullScanProgress = self . fullScanProgress {
@@ -200,7 +198,6 @@ final class KyotoService: BDKSyncService {
200
198
if let warn = try ? await self . client? . nextWarning ( ) {
201
199
switch warn {
202
200
case . needConnections:
203
- print ( " ######### disconnected " )
204
201
self . isConnected = false
205
202
default :
206
203
#if DEBUG
0 commit comments