@@ -51,7 +51,7 @@ import Ntp.Util (AddrFamily (..), Addresses, EitherOrBoth (..),
51
51
import Pos.Util.Trace (traceWith )
52
52
53
53
data NtpStatus =
54
- -- | The difference between ntp time and local system time
54
+ -- | The difference between NTP time and local system time
55
55
NtpDrift NtpOffset
56
56
-- | NTP client has send requests to the servers
57
57
| NtpSyncPending
@@ -164,12 +164,12 @@ sendLoop cli addrs = do
164
164
165
165
() <- withAsync
166
166
(do
167
- -- wait for reponses and update status
167
+ -- wait for responses and update status
168
168
_ <- timeout respTimeout waitForResponses
169
169
updateStatus cli
170
170
)
171
171
(\ a -> do
172
- -- send packets and wait untill end of poll delay
172
+ -- send packets and wait until end of poll delay
173
173
sock <- atomically $ readTVar $ ncSockets cli
174
174
pack <- mkNtpPacket
175
175
sendPacket sock pack addrs
@@ -193,7 +193,7 @@ sendLoop cli addrs = do
193
193
logDebug " collected all responses"
194
194
195
195
-- |
196
- -- Start listening for responses on the socket ` ncSockets
196
+ -- Start listening for responses on the socket @' ncSockets'@
197
197
startReceive :: NtpClient -> IO ()
198
198
startReceive cli =
199
199
atomically (readTVar $ ncSockets cli) >>= \ case
@@ -206,7 +206,7 @@ startReceive cli =
206
206
EBSecond (Last (WithIPv4 sock_ipv4)) ->
207
207
loop IPv4 sock_ipv4
208
208
where
209
- -- Receive responses from the network and update ntp client state.
209
+ -- Receive responses from the network and update NTP client state.
210
210
loop :: AddrFamily -> Socket. Socket -> IO ()
211
211
loop addressFamily sock
212
212
= handle (handleIOException addressFamily) $ forever $ do
@@ -217,7 +217,7 @@ startReceive cli =
217
217
Right (_, _, packet) ->
218
218
handleNtpPacket packet
219
219
220
- -- Restart the @loop@ in case of errors; wait 5s before recreacting the
220
+ -- Restart the @loop@ in case of errors; wait 5s before recreating the
221
221
-- socket.
222
222
handleIOException
223
223
:: AddrFamily
@@ -238,8 +238,8 @@ startReceive cli =
238
238
EBBoth _ _
239
239
-> error " NtpClient: startReceive: impossible"
240
240
241
- -- Compute the clock offset based on current time and record it in the ntp
242
- -- client state. A packet will be digarded if it came after
241
+ -- Compute the clock offset based on current time and record it in the NTP
242
+ -- client state. A packet will be disgarded if it came after
243
243
-- @'ntpResponseTimeout'@.
244
244
handleNtpPacket
245
245
:: NtpPacket
@@ -256,10 +256,10 @@ startReceive cli =
256
256
atomically $ modifyTVar' (ncState cli) ( offset : )
257
257
258
258
-- |
259
- -- Spawn ntp client which will send request to ntp servers every ntpPollDelay
260
- -- and will lisent for responses. The ` ncStatus` will be updated every
261
- -- ` ntpPollDelay` with the most recent value. It should be run in a seprate
262
- -- thread, since it will block infinitelly .
259
+ -- Spawn NTP client which will send request to NTP servers every @' ntpPollDelay'@
260
+ -- and will listen for responses. The @' ncStatus'@ will be updated every
261
+ -- @' ntpPollDelay'@ with the most recent value. It should be run in a separate
262
+ -- thread, since it will block infinitely .
263
263
spawnNtpClient :: NtpClientSettings -> TVar NtpStatus -> IO ()
264
264
spawnNtpClient settings ncStatus = do
265
265
logInfo " starting"
@@ -281,16 +281,16 @@ spawnNtpClient settings ncStatus = do
281
281
fn (Last sock) = Socket. close $ runWithAddrFamily sock
282
282
283
283
-- |
284
- -- Run Ntp client in a seprate thread; it returns a mutable cell which holds
285
- -- ` NtpStatus` .
284
+ -- Run NTP client in a separate thread; it returns a mutable cell which holds
285
+ -- @' NtpStatus'@ .
286
286
--
287
- -- This function should be called once, it will run an ntp client in a new
288
- -- thread untill the program terminates.
287
+ -- This function should be called once, it will run an NTP client in a new
288
+ -- thread until the program terminates.
289
289
withNtpClient :: MonadIO m => NtpClientSettings -> m (TVar NtpStatus )
290
290
withNtpClient ntpSettings = do
291
291
liftIO $ logInfo " withNtpClient"
292
292
ncStatus <- newTVarIO NtpSyncPending
293
- -- using async so the ntp thread will be left running even if the parent
293
+ -- using async so the NTP thread will be left running even if the parent
294
294
-- thread finished.
295
295
_ <- liftIO $ async (spawnNtpClient ntpSettings ncStatus)
296
296
return ncStatus
0 commit comments