[#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
This commit is contained in:
parent
cbfa73181d
commit
545380b3e2
|
@ -13,7 +13,9 @@ extension CompactBlockProcessor {
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
|
|
||||||
setState(.scanning)
|
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 {
|
do {
|
||||||
if batchSize == 0 {
|
if batchSize == 0 {
|
||||||
|
@ -92,6 +94,17 @@ extension CompactBlockProcessor {
|
||||||
throw error
|
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 {
|
extension CompactBlockProcessor {
|
||||||
|
|
Loading…
Reference in New Issue