[#1128] Fix switch to error state after Synchronizer.prepare() call
Closes #1128
This commit is contained in:
parent
ee3d082155
commit
9144f26b35
|
@ -104,9 +104,9 @@ public class SDKSynchronizer: Synchronizer {
|
|||
}
|
||||
}
|
||||
|
||||
func updateStatus(_ newValue: InternalSyncStatus) async {
|
||||
func updateStatus(_ newValue: InternalSyncStatus, updateExternalStatus: Bool = true) async {
|
||||
let oldValue = await underlyingStatus.update(newValue)
|
||||
await notify(oldStatus: oldValue, newStatus: newValue)
|
||||
await notify(oldStatus: oldValue, newStatus: newValue, updateExternalStatus: updateExternalStatus)
|
||||
}
|
||||
|
||||
func throwIfUnprepared() throws {
|
||||
|
@ -148,7 +148,7 @@ public class SDKSynchronizer: Synchronizer {
|
|||
await latestBlocksDataProvider.updateWalletBirthday(initializer.walletBirthday)
|
||||
await latestBlocksDataProvider.updateScannedData()
|
||||
|
||||
await updateStatus(.disconnected)
|
||||
await updateStatus(.disconnected, updateExternalStatus: false)
|
||||
|
||||
return .success
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ public class SDKSynchronizer: Synchronizer {
|
|||
)
|
||||
}
|
||||
|
||||
private func notify(oldStatus: InternalSyncStatus, newStatus: InternalSyncStatus) async {
|
||||
private func notify(oldStatus: InternalSyncStatus, newStatus: InternalSyncStatus, updateExternalStatus: Bool = true) async {
|
||||
guard oldStatus != newStatus else { return }
|
||||
|
||||
let newState: SynchronizerState
|
||||
|
@ -590,7 +590,10 @@ public class SDKSynchronizer: Synchronizer {
|
|||
}
|
||||
|
||||
latestState = newState
|
||||
updateStateStream(with: latestState)
|
||||
|
||||
if updateExternalStatus {
|
||||
updateStateStream(with: latestState)
|
||||
}
|
||||
}
|
||||
|
||||
private func updateStateStream(with newState: SynchronizerState) {
|
||||
|
|
|
@ -186,10 +186,10 @@ class SynchronizerDarksideTests: ZcashTestCase {
|
|||
syncSessionID: .nullID,
|
||||
shieldedBalance: .zero,
|
||||
transparentBalance: .zero,
|
||||
internalSyncStatus: .disconnected,
|
||||
latestScannedHeight: 663150,
|
||||
internalSyncStatus: .unprepared,
|
||||
latestScannedHeight: 0,
|
||||
latestBlockHeight: 0,
|
||||
latestScannedTime: 1576821833
|
||||
latestScannedTime: 0
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
|
@ -350,10 +350,10 @@ class SynchronizerDarksideTests: ZcashTestCase {
|
|||
syncSessionID: .nullID,
|
||||
shieldedBalance: .zero,
|
||||
transparentBalance: .zero,
|
||||
internalSyncStatus: .disconnected,
|
||||
latestScannedHeight: 663150,
|
||||
internalSyncStatus: .unprepared,
|
||||
latestScannedHeight: 0,
|
||||
latestBlockHeight: 0,
|
||||
latestScannedTime: 1576821833.0
|
||||
latestScannedTime: 0
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
|
|
Loading…
Reference in New Issue