From 545380b3e250faee22c7b1d616d5ba749af9373d Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Tue, 25 Oct 2022 18:21:32 -0300 Subject: [PATCH 1/2] [#577] Fix: reduce batch size when reaching increased load part of the chain Currently a 100 batch can take up to 3 minutes to scan. decrease the size of the batches when the increased load part of the chain is reached until a faster sync is implemented See related counterpart to remove it issue #576 Closes #577 --- .../Block/Processor/CompactBlockScanning.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/ZcashLightClientKit/Block/Processor/CompactBlockScanning.swift b/Sources/ZcashLightClientKit/Block/Processor/CompactBlockScanning.swift index f85f1b8d..45b2b34c 100644 --- a/Sources/ZcashLightClientKit/Block/Processor/CompactBlockScanning.swift +++ b/Sources/ZcashLightClientKit/Block/Processor/CompactBlockScanning.swift @@ -13,7 +13,9 @@ extension CompactBlockProcessor { try Task.checkCancellation() setState(.scanning) - let batchSize = UInt32(config.scanningBatchSize) + + // TODO: remove this arbitrary batch size https://github.com/zcash/ZcashLightClientKit/issues/576 + let batchSize = scanBatchSize(for: range, network: self.config.network.networkType) do { if batchSize == 0 { @@ -92,6 +94,17 @@ extension CompactBlockProcessor { throw error } } + + fileprivate func scanBatchSize(for range: CompactBlockRange, network: NetworkType) -> UInt32 { + guard network == .mainnet else { + return UInt32(config.scanningBatchSize) + } + if range.lowerBound > 1_600_000 { + return 5 + } + + return UInt32(config.scanningBatchSize) + } } extension CompactBlockProcessor { From fc2f7aa05587e994a7bb3922f7afbae15709695d Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Wed, 26 Oct 2022 16:44:08 -0300 Subject: [PATCH 2/2] Change version on podspec to release alpha --- ZcashLightClientKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZcashLightClientKit.podspec b/ZcashLightClientKit.podspec index 6b23ca6c..f1163102 100644 --- a/ZcashLightClientKit.podspec +++ b/ZcashLightClientKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ZcashLightClientKit' - s.version = '0.16.10-beta' + s.version = '0.17.0-alpha.1' s.summary = 'Zcash Light Client wallet SDK for iOS' s.description = <<-DESC