improve status publishing for SDKSynchronizer

This commit is contained in:
Francisco Gindre 2021-07-06 15:31:04 -03:00
parent c2777dc520
commit 834842187e
2 changed files with 21 additions and 1 deletions

View File

@ -393,3 +393,23 @@ extension SyncStatus {
}
}
}
extension SyncStatus {
init(_ blockProcessorProgress: CompactBlockProgress) {
switch blockProcessorProgress {
case .download(let progressReport):
self = SyncStatus.downloading(progressReport)
case .validate:
self = .validating
case .scan(let progressReport):
self = .scanning(progressReport)
case .enhance(let enhancingReport):
self = .enhancing(enhancingReport)
case .fetch:
self = .fetching
}
}
}

View File

@ -643,7 +643,7 @@ public class SDKSynchronizer: Synchronizer {
userInfo[NotificationKeys.progress] = progress
userInfo[NotificationKeys.blockHeight] = progress.progressHeight
userInfo[NotificationKeys.blockDate] = progress.progressHeight
self.status = SyncStatus(progress)
NotificationCenter.default.post(name: Notification.Name.synchronizerProgressUpdated, object: self, userInfo: userInfo)
}