From 8e88e648f37c16720247c3f6c6f3752778a4214c Mon Sep 17 00:00:00 2001 From: Alexander Mokrushin Date: Mon, 27 Nov 2023 23:48:29 +0300 Subject: [PATCH] Added isStarted property to TrueTimeClient and NTPClient. This allows to avoid crash on check: precondition(self.reachability.callback == nil, "Already started") --- Sources/NTPClient.swift | 1 + Sources/TrueTime.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Sources/NTPClient.swift b/Sources/NTPClient.swift index e340749..94ea71a 100644 --- a/Sources/NTPClient.swift +++ b/Sources/NTPClient.swift @@ -92,6 +92,7 @@ final class NTPClient { private var pool: [String] = [] { didSet { invalidate() } } + var isStarted: Bool { return self.reachability.callback != nil } } private extension NTPClient { diff --git a/Sources/TrueTime.swift b/Sources/TrueTime.swift index a588a4e..a76f43c 100644 --- a/Sources/TrueTime.swift +++ b/Sources/TrueTime.swift @@ -92,6 +92,7 @@ public typealias LogCallback = (String) -> Void @objc public var maxConnections: Int { return config.maxConnections } @objc public var maxServers: Int { return config.maxServers} @objc public var numberOfSamples: Int { return config.numberOfSamples} + @objc public var isStarted: Bool { return ntp.isStarted } private let config: NTPConfig private let ntp: NTPClient