[#1049] Implement ValidateAction

Closes #1049
This commit is contained in:
Michal Fousek 2023-05-10 14:22:58 +02:00
parent 3737b841ef
commit 4b366b68c0
1 changed files with 5 additions and 4 deletions

View File

@ -8,14 +8,15 @@
import Foundation import Foundation
class ValidateAction { class ValidateAction {
init(container: DIContainer) { } let validator: BlockValidator
init(container: DIContainer) {
validator = container.resolve(BlockValidator.self)
}
} }
extension ValidateAction: Action { extension ValidateAction: Action {
func run(with context: ActionContext, didUpdate: @escaping (ActionProgress) async -> Void) async throws -> ActionContext { func run(with context: ActionContext, didUpdate: @escaping (ActionProgress) async -> Void) async throws -> ActionContext {
try await validator.validate()
// Wait until all blocks in range latestScannedHeight...latestScannedHeight+batchSize are downloaded and then run validation.
await context.update(state: .scan) await context.update(state: .scan)
return context return context
} }