instacart / TrueTime.swift

NTP library for Swift and Objective-C. Get the true time impervious to device clock changes.
https://tech.instacart.com/truetime/
Apache License 2.0
589 stars 131 forks source link

Added isStarted property to TrueTimeClient and NTPClient. #111

Open AlexMokrushin opened 10 months ago

AlexMokrushin commented 10 months ago

What did you change and why?

Added isStarted property to TrueTimeClient and NTPClient. If start() is called occasionally twice, app crashes on check :

precondition(self.reachability.callback == nil, "Already started")

We can avoid this crash calling start() like that:

let client = TrueTimeClient.sharedInstance
if (!client.isStarted) {
    client.start(pool: [NTP_HOST], port: NTP_PORT)
}

Potential risks introduced?

No new risks.

What tests were performed (include steps)?

Manual tests.

Checklist