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