@@ -29,7 +29,6 @@ import Control.Concurrent.Class.MonadSTM.Strict (
29
29
StrictTBQueue (.. ),
30
30
flushTBQueue ,
31
31
isEmptyTBQueue ,
32
- readTBQueue ,
33
32
writeTBQueue ,
34
33
)
35
34
import Control.Monad.Trans.Control (MonadBaseControl )
@@ -84,8 +83,8 @@ loadOffChainWorkQueue ::
84
83
loadOffChainWorkQueue _trce offChainWorkQueue = do
85
84
whenM (liftIO $ atomically (isEmptyTBQueue (lQueue offChainWorkQueue))) $ do
86
85
now <- liftIO Time. getPOSIXTime
87
- runnableOffChainPools <- filter (isRunnable now offChainWorkQueue) <$> lGetData offChainWorkQueue now 100
88
- liftIO $ mapM_ (queueInsert offChainWorkQueue) runnableOffChainPools
86
+ runnableOffChainData <- filter (isRunnable now offChainWorkQueue) <$> lGetData offChainWorkQueue now 100
87
+ liftIO $ mapM_ (queueInsert offChainWorkQueue) runnableOffChainData
89
88
where
90
89
isRunnable :: POSIXTime -> LoadOffChainWorkQueue a m -> a -> Bool
91
90
isRunnable now oCWorkQueue locWq = retryRetryTime (lRetryTime oCWorkQueue locWq) <= now
@@ -172,7 +171,7 @@ runFetchOffChainPoolThread syncEnv = do
172
171
tDelay
173
172
-- load the offChain vote work queue using the db
174
173
_ <- runReaderT (loadOffChainPoolWorkQueue trce (envOffChainPoolWorkQueue syncEnv)) (envBackend syncEnv)
175
- poolq <- blockingFlushTBQueue (envOffChainPoolWorkQueue syncEnv)
174
+ poolq <- atomically $ flushTBQueue (envOffChainPoolWorkQueue syncEnv)
176
175
manager <- Http. newManager tlsManagerSettings
177
176
now <- liftIO Time. getPOSIXTime
178
177
mapM_ (queuePoolInsert <=< fetchOffChainPoolData trce manager now) poolq
@@ -192,7 +191,7 @@ runFetchOffChainVoteThread syncEnv = do
192
191
tDelay
193
192
-- load the offChain pool work queue using the db
194
193
_ <- runReaderT (loadOffChainVoteWorkQueue trce (envOffChainVoteWorkQueue syncEnv)) (envBackend syncEnv)
195
- voteq <- blockingFlushTBQueue (envOffChainVoteWorkQueue syncEnv)
194
+ voteq <- atomically $ flushTBQueue (envOffChainVoteWorkQueue syncEnv)
196
195
manager <- Http. newManager tlsManagerSettings
197
196
now <- liftIO Time. getPOSIXTime
198
197
mapM_ (queueVoteInsert <=< fetchOffChainVoteData trce manager now) voteq
@@ -207,16 +206,6 @@ runFetchOffChainVoteThread syncEnv = do
207
206
tDelay :: IO ()
208
207
tDelay = threadDelay 60_000_000
209
208
210
- -- -------------------------------------------------------------------------------------------------
211
-
212
- -- Blocks on an empty queue, but gets all elements in the queue if there is more than one.
213
- blockingFlushTBQueue :: StrictTBQueue IO a -> IO [a ]
214
- blockingFlushTBQueue queue = do
215
- atomically $ do
216
- x <- readTBQueue queue
217
- xs <- flushTBQueue queue
218
- pure $ x : xs
219
-
220
209
---------------------------------------------------------------------------------------------------------------------------------
221
210
-- Fetch OffChain data
222
211
---------------------------------------------------------------------------------------------------------------------------------
0 commit comments