@@ -130,18 +130,23 @@ processServer
130
130
-> WithContext m ()
131
131
processServer opts@ ProcessOptions {poPollIntervalSeconds} = do
132
132
liftIO $ putStrLn " Starting oracle process server..."
133
- let loop :: WithContext m () = do
133
+ let waitLoop = do
134
+ liftIO
135
+ $ putStrLn
136
+ $ " Sleeping for "
137
+ ++ show poPollIntervalSeconds
138
+ ++ " seconds..."
139
+ liftIO $ threadDelay (poPollIntervalSeconds * 1000000 )
140
+ loop
141
+
142
+ loop :: WithContext m () = do
134
143
liftIO $ putStrLn " Polling for new requests..."
135
144
reqIds <- liftIO $ poll opts
136
145
if null reqIds
137
146
then do
138
147
liftIO
139
- $ putStrLn
140
- $ " No new requests found. Sleeping for "
141
- ++ show poPollIntervalSeconds
142
- ++ " seconds..."
143
- liftIO $ threadDelay (poPollIntervalSeconds * 1000000 )
144
- loop
148
+ $ putStrLn " No new requests found."
149
+ waitLoop
145
150
else do
146
151
liftIO
147
152
$ putStrLn
@@ -166,19 +171,21 @@ processServer opts@ProcessOptions{poPollIntervalSeconds} = do
166
171
$ putStrLn
167
172
$ " Successfully submitted batch with tx hash: "
168
173
++ show txHash
169
- loop
174
+ waitLoop
170
175
loop
171
176
poll :: ProcessOptions -> IO [RequestRefId ]
172
177
poll ProcessOptions {poTokenId, poMPFSClient, poAuth} = do
173
178
result <- cmd (GetToken poAuth poMPFSClient poTokenId)
174
179
case result of
175
180
ValidationFailure err -> error $ " Failed to get token: " ++ show err
176
- ValidationSuccess token -> pure
177
- $ fmap (requestZooRefId . request)
178
- $ flip filter (tokenRequests token)
179
- $ \ (WithValidation v _) -> case v of
180
- ValidationFailure _err -> False
181
- ValidationSuccess Validated -> True
181
+ ValidationSuccess token -> do
182
+ print $ tokenRequests token
183
+ pure
184
+ $ fmap (requestZooRefId . request)
185
+ $ flip filter (tokenRequests token)
186
+ $ \ (WithValidation v _) -> case v of
187
+ ValidationFailure _err -> False
188
+ ValidationSuccess Validated -> True
182
189
183
190
batch :: ProcessOptions -> [RequestRefId ] -> [[RequestRefId ]]
184
191
batch ProcessOptions {poMaxRequestsPerBatch} = go
0 commit comments