34 lines
835 B
Swift
34 lines
835 B
Swift
//
|
|
// FetchUTXOsAction.swift
|
|
//
|
|
//
|
|
// Created by Michal Fousek on 05.05.2023.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
final class FetchUTXOsAction {
|
|
let utxoFetcher: UTXOFetcher
|
|
let logger: Logger
|
|
|
|
init(container: DIContainer) {
|
|
utxoFetcher = container.resolve(UTXOFetcher.self)
|
|
logger = container.resolve(Logger.self)
|
|
}
|
|
}
|
|
|
|
extension FetchUTXOsAction: Action {
|
|
var removeBlocksCacheWhenFailed: Bool { false }
|
|
|
|
func run(with context: ActionContext, didUpdate: @escaping (CompactBlockProcessor.Event) async -> Void) async throws -> ActionContext {
|
|
logger.debug("Fetching UTXOs")
|
|
let result = try await utxoFetcher.fetch() { _ in }
|
|
await didUpdate(.storedUTXOs(result))
|
|
|
|
await context.update(state: .handleSaplingParams)
|
|
return context
|
|
}
|
|
|
|
func stop() async { }
|
|
}
|