[#1288] Extend SyncStatus with stopped state

- InternalSyncStatus as well as SyncStatus were extended with stopped state, this is needed to distinguish between upToDate and stopped via stop() method states as previously stopped state of block processor was mapped to upToDate
This commit is contained in:
Lukas Korba 2023-09-25 16:33:04 +02:00
parent d8b069fd15
commit 13b994d2a5
4 changed files with 16 additions and 5 deletions

View File

@ -316,6 +316,9 @@ extension SDKSynchronizer {
case .unprepared:
return "Unprepared 😅"
case .stopped:
return "Stopped"
case .error(ZcashError.synchronizerDisconnected):
return "disconnected 💔"

View File

@ -64,7 +64,7 @@ class SyncBlocksListViewController: UIViewController {
loggerProxy.debug("Processing synchronizer with alias \(synchronizer.alias.description) \(index)")
switch syncStatus {
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error:
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error, .stopped:
do {
if syncStatus == .unprepared {
_ = try! await synchronizer.prepare(
@ -145,7 +145,7 @@ extension SyncBlocksListViewController: UITableViewDataSource {
let image: UIImage?
switch synchronizerStatus {
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error:
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error, .stopped:
image = UIImage(systemName: "play.circle")
case .syncing:
image = UIImage(systemName: "stop.circle")
@ -176,6 +176,8 @@ extension SyncStatus {
return "Up to Date 😎"
case .unprepared:
return "Unprepared"
case .stopped:
return "Stopped"
case .error(ZcashError.synchronizerDisconnected):
return "Disconnected"
case let .error(error):

View File

@ -93,7 +93,7 @@ class SyncBlocksViewController: UIViewController {
metricLabel.text = currentMetricName + report.debugDescription
}
case .upToDate:
case .upToDate, .stopped:
accumulateMetrics()
summaryLabel.text = "enhancement: \(accumulatedMetrics.debugDescription)"
overallSummary()
@ -205,7 +205,7 @@ class SyncBlocksViewController: UIViewController {
switch state {
case .syncing:
return "Pause"
case .unprepared:
case .unprepared, .stopped:
return "Start"
case .upToDate:
return "Chill!"
@ -222,6 +222,8 @@ class SyncBlocksViewController: UIViewController {
return "Up to Date 😎"
case .unprepared:
return "Unprepared"
case .stopped:
return "Stopped"
case .error(ZcashError.synchronizerDisconnected):
return "Disconnected"
case .error:

View File

@ -317,6 +317,9 @@ public enum SyncStatus: Equatable {
/// When set, a UI element may want to turn green.
case upToDate
/// Indicates that this Synchronizer was succesfully stopped via `stop()` method.
case stopped
case error(_ error: Error)
public var isSyncing: Bool {
@ -347,6 +350,7 @@ public enum SyncStatus: Equatable {
switch self {
case .unprepared: return "unprepared"
case .syncing: return "syncing"
case .stopped: return "stopped"
case .upToDate: return "up to date"
case .error: return "error"
}
@ -469,7 +473,7 @@ extension InternalSyncStatus {
case .synced:
return .upToDate
case .stopped:
return .upToDate
return .stopped
case .disconnected:
return .error(ZcashError.synchronizerDisconnected)
case .error(let error):