[#1041] Implement ClearCacheAction

Closes #1041
This commit is contained in:
Michal Fousek 2023-05-12 11:16:20 +02:00
parent d40f3d3675
commit 687abff8d0
1 changed files with 5 additions and 2 deletions

View File

@ -8,14 +8,17 @@
import Foundation
class ClearCacheAction {
init(container: DIContainer) { }
let storage: CompactBlockRepository
init(container: DIContainer) {
storage = container.resolve(CompactBlockRepository.self)
}
}
extension ClearCacheAction: Action {
var removeBlocksCacheWhenFailed: Bool { false }
func run(with context: ActionContext, didUpdate: @escaping (CompactBlockProcessorNG.Event) async -> Void) async throws -> ActionContext {
// clear storage
try await storage.clear()
await context.update(state: .finished)
return context
}