-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1167] Step 3 - Download chain tip metadata from lightwalletd
- update chain tip action added [#1167] Step 3 - Download chain tip metadata from lightwalletd - roots removed from the ActionContext [#1167] Step 3 - Download chain tip metadata from lightwalletd - fallback to linear sync until next step is implemented
- Loading branch information
1 parent
3fd68f8
commit 0db27c4
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Sources/ZcashLightClientKit/Block/Actions/UpdateChainTipAction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// UpdateChainTipAction.swift | ||
// | ||
// | ||
// Created by Lukáš Korba on 01.08.2023. | ||
// | ||
|
||
import Foundation | ||
|
||
final class UpdateChainTipAction { | ||
let rustBackend: ZcashRustBackendWelding | ||
let service: LightWalletService | ||
let logger: Logger | ||
|
||
init(container: DIContainer) { | ||
service = container.resolve(LightWalletService.self) | ||
rustBackend = container.resolve(ZcashRustBackendWelding.self) | ||
logger = container.resolve(Logger.self) | ||
} | ||
} | ||
|
||
extension UpdateChainTipAction: Action { | ||
var removeBlocksCacheWhenFailed: Bool { false } | ||
|
||
func run(with context: ActionContext, didUpdate: @escaping (CompactBlockProcessor.Event) async -> Void) async throws -> ActionContext { | ||
let latestBlockHeight = try await service.latestBlockHeight() | ||
|
||
logger.info("Latest block height is \(latestBlockHeight)") | ||
try await rustBackend.updateChainTip(height: Int32(latestBlockHeight)) | ||
|
||
// TODO: [#1169] Switching back to linear sync for now before step 5 & 6 are implemented | ||
// https://github.com/zcash/ZcashLightClientKit/issues/1169 | ||
await context.update(state: .computeSyncControlData) | ||
|
||
return context | ||
} | ||
|
||
func stop() async { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters