File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ import Cardano.BM.Data.Tracer
2626 ( HasPrivacyAnnotation (.. ), HasSeverityAnnotation (.. ) )
2727import Cardano.Wallet.Api.Types
2828 ( ApiNetworkClock (.. ), ApiNtpStatus (.. ), NtpSyncingStatus (.. ) )
29- import Control.Monad .STM
30- ( atomically )
29+ import Control.Concurrent .STM
30+ ( atomically , check )
3131import Control.Tracer
3232 ( Tracer )
3333import Data.Quantity
@@ -130,12 +130,17 @@ getNtpStatus
130130 -> IO ApiNetworkClock
131131getNtpStatus client forceCheck = (ApiNetworkClock . toStatus) <$>
132132 if forceCheck
133- then ntpQueryBlocking client
134- -- ^ Forces an NTP check / query on the central servers, use with care
135- else atomically (ntpGetStatus client)
136- -- ^ Reads a cached NTP status from an STM.TVar so we don't get
137- -- blacklisted by the central NTP "authorities" for sending too many NTP
138- -- requests.
133+ -- Forces an NTP check / query on the central servers, use with care
134+ then do
135+ ntpQueryBlocking client
136+
137+ else atomically $ do
138+ -- Reads a cached NTP status from an STM.TVar so we don't get
139+ -- blacklisted by the central NTP "authorities" for sending too many NTP
140+ -- requests.
141+ s <- ntpGetStatus client
142+ check (s /= NtpSyncPending )
143+ pure s
139144 where
140145 toStatus = \ case
141146 NtpSyncPending ->
You can’t perform that action at this time.
0 commit comments