Merge pull request #6979 from AlphaWallet/refactoring-rename

[Refactoring] rename property and method arg to be more intention revealing
pull/6980/head
Hwee-Boon Yar 1 year ago committed by GitHub
commit a1524dae2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/AlphaWalletFoundation/AlphaWalletFoundation/GasPriceEstimator/Eip1559GasPriceEstimator.swift
  2. 2
      modules/AlphaWalletFoundation/AlphaWalletFoundation/GasPriceEstimator/LegacyGasPriceEstimator.swift
  3. 13
      modules/AlphaWalletFoundation/AlphaWalletFoundation/Transactions/Scheduler.swift

@ -19,7 +19,7 @@ public final class Eip1559GasPriceEstimator: NSObject, GasPriceEstimator {
private let initialMaxFeePerGas: BigUInt?
private let initialMaxPriorityFeePerGas: BigUInt?
private var cancellable = Set<AnyCancellable>()
private lazy var scheduler = Scheduler(provider: estimatesProvider, useCountdownTimer: true)
private lazy var scheduler = Scheduler(provider: estimatesProvider, refreshAggressively: true)
private let estimatesProvider: Eip1559GasPriceEstimatorProvider
public private(set) var selectedGasSpeed: GasSpeed = .standard

@ -22,7 +22,7 @@ public final class LegacyGasPriceEstimator: NSObject, GasPriceEstimator {
private let estimatesSubject: CurrentValueSubject<LegacyGasEstimates, Never>
private let initialGasPrice: BigUInt?
private var cancellable = Set<AnyCancellable>()
private lazy var scheduler = Scheduler(provider: estimatesProvider, useCountdownTimer: true)
private lazy var scheduler = Scheduler(provider: estimatesProvider, refreshAggressively: true)
private let estimatesProvider: LegacyEstimatesSchedulerProvider
public private(set) var selectedGasSpeed: GasSpeed = .standard

@ -47,7 +47,7 @@ enum SchedulerError: Error {
final class Scheduler: SchedulerProtocol {
private lazy var timer = CombineTimer(interval: provider.interval)
private var countdownTimer: CombineTimer?
private var refreshAggressivelyTimer: CombineTimer?
private let reachability: ReachabilityManagerProtocol
private lazy var queue = RunLoop.main
private var cancelable = Set<AnyCancellable>()
@ -58,16 +58,13 @@ final class Scheduler: SchedulerProtocol {
@Published var state: Scheduler.State = .idle
let provider: SchedulerProvider
init(provider: SchedulerProvider,
reachability: ReachabilityManagerProtocol = ReachabilityManager(),
useCountdownTimer: Bool = false) {
init(provider: SchedulerProvider, reachability: ReachabilityManagerProtocol = ReachabilityManager(), refreshAggressively: Bool = false) {
self.reachability = reachability
self.provider = provider
if useCountdownTimer {
if refreshAggressively {
let timer = CombineTimer(interval: 1)
countdownTimer = timer
refreshAggressivelyTimer = timer
timer.publisher
.compactMap { _ -> Scheduler.State? in
guard case .tick(let value) = self.state, value - 1 >= 0 else { return nil }
@ -90,7 +87,7 @@ final class Scheduler: SchedulerProtocol {
private func resetCountdownCounter() {
self.state = .tick(Int(provider.interval))
countdownTimer?.interval = 1
refreshAggressivelyTimer?.interval = 1
}
func restart(force: Bool = false) {

Loading…
Cancel
Save