[#1048] Implement ScanDownloadedButUnscannedAction
- scan downloaded but unscanned blocks
This commit is contained in:
parent
3193d025b4
commit
c127735ec3
|
@ -8,25 +8,31 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class ScanDownloadedButUnscannedAction {
|
class ScanDownloadedButUnscannedAction {
|
||||||
init(container: DIContainer) { }
|
let logger: Logger
|
||||||
|
let blockScanner: BlockScanner
|
||||||
|
|
||||||
|
init(container: DIContainer) {
|
||||||
|
logger = container.resolve(Logger.self)
|
||||||
|
blockScanner = container.resolve(BlockScanner.self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ScanDownloadedButUnscannedAction: Action {
|
extension ScanDownloadedButUnscannedAction: Action {
|
||||||
var removeBlocksCacheWhenFailed: Bool { false }
|
var removeBlocksCacheWhenFailed: Bool { false }
|
||||||
|
|
||||||
func run(with context: ActionContext, didUpdate: @escaping (CompactBlockProcessorNG.Event) async -> Void) async throws -> ActionContext {
|
func run(with context: ActionContext, didUpdate: @escaping (CompactBlockProcessorNG.Event) async -> Void) async throws -> ActionContext {
|
||||||
// if let range = ranges.downloadedButUnscannedRange {
|
if let range = await context.syncRanges.downloadedButUnscannedRange {
|
||||||
// logger.debug("Starting scan with downloaded but not scanned blocks with range: \(range.lowerBound)...\(range.upperBound)")
|
logger.debug("Starting scan with downloaded but not scanned blocks with range: \(range.lowerBound)...\(range.upperBound)")
|
||||||
// try await blockScanner.scanBlocks(at: range, totalProgressRange: totalProgressRange) { [weak self] lastScannedHeight in
|
let totalProgressRange = await context.totalProgressRange
|
||||||
// let progress = BlockProgress(
|
try await blockScanner.scanBlocks(at: range, totalProgressRange: totalProgressRange) { lastScannedHeight in
|
||||||
// startHeight: totalProgressRange.lowerBound,
|
let progress = BlockProgress(
|
||||||
// targetHeight: totalProgressRange.upperBound,
|
startHeight: totalProgressRange.lowerBound,
|
||||||
// progressHeight: lastScannedHeight
|
targetHeight: totalProgressRange.upperBound,
|
||||||
// )
|
progressHeight: lastScannedHeight
|
||||||
// await self?.notifyProgress(.syncing(progress))
|
)
|
||||||
// }
|
await didUpdate(.progressUpdated(.syncing(progress)))
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
await context.update(state: .download)
|
await context.update(state: .download)
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue