[#1412] Review wipe function and in memory values
- The wipe() is now resetting local in memory values of latestBlocksDataProvider. In some case this could cause a reset of CBP's state machine context sooner than it was supposed to, resulting in corrupted sync.
This commit is contained in:
parent
652bacd3d8
commit
ffc7fd1be9
|
@ -6,6 +6,12 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
# Unreleased
|
||||
|
||||
## Changed
|
||||
- The database locking mechanism has been changed to use async/await concurrency approach - the DBActor.
|
||||
|
||||
## Fixed
|
||||
- Call of wipe() resets local (in memory) values.
|
||||
|
||||
# 2.1.3 - 2024-03-28
|
||||
|
||||
## Fixed
|
||||
|
|
|
@ -386,6 +386,8 @@ extension CompactBlockProcessor {
|
|||
|
||||
try await rewindDownloadBlockAction(to: nil)
|
||||
|
||||
await latestBlocksDataProvider.reset()
|
||||
|
||||
await context.completion(nil)
|
||||
} catch {
|
||||
await context.completion(error)
|
||||
|
|
|
@ -12,7 +12,8 @@ protocol LatestBlocksDataProvider {
|
|||
var maxScannedHeight: BlockHeight { get async }
|
||||
var latestBlockHeight: BlockHeight { get async }
|
||||
var walletBirthday: BlockHeight { get async }
|
||||
|
||||
|
||||
func reset() async
|
||||
func updateScannedData() async
|
||||
func updateBlockData() async
|
||||
func updateWalletBirthday(_ walletBirthday: BlockHeight) async
|
||||
|
@ -36,6 +37,13 @@ actor LatestBlocksDataProviderImpl: LatestBlocksDataProvider {
|
|||
self.rustBackend = rustBackend
|
||||
}
|
||||
|
||||
func reset() async {
|
||||
fullyScannedHeight = .zero
|
||||
maxScannedHeight = .zero
|
||||
latestBlockHeight = .zero
|
||||
walletBirthday = .zero
|
||||
}
|
||||
|
||||
func updateScannedData() async {
|
||||
fullyScannedHeight = (try? await rustBackend.fullyScannedHeight()) ?? walletBirthday
|
||||
maxScannedHeight = (try? await rustBackend.maxScannedHeight()) ?? walletBirthday
|
||||
|
|
|
@ -671,6 +671,19 @@ class LatestBlocksDataProviderMock: LatestBlocksDataProvider {
|
|||
}
|
||||
var underlyingWalletBirthday: BlockHeight!
|
||||
|
||||
// MARK: - reset
|
||||
|
||||
var resetCallsCount = 0
|
||||
var resetCalled: Bool {
|
||||
return resetCallsCount > 0
|
||||
}
|
||||
var resetClosure: (() async -> Void)?
|
||||
|
||||
func reset() async {
|
||||
resetCallsCount += 1
|
||||
await resetClosure!()
|
||||
}
|
||||
|
||||
// MARK: - updateScannedData
|
||||
|
||||
var updateScannedDataCallsCount = 0
|
||||
|
|
Loading…
Reference in New Issue