Skip to content

Instantly share code, notes, and snippets.

@dmp1ce
Last active November 13, 2019 18:22
Show Gist options
  • Save dmp1ce/61528228505bc8d9b997e62f4944f13f to your computer and use it in GitHub Desktop.
Save dmp1ce/61528228505bc8d9b997e62f4944f13f to your computer and use it in GitHub Desktop.
tryCommand h p c = do
re <- try (sendCGMinerCommand h p c)
let r = case re of
Right a -> a
Left (SomeException e) -> error $ "sendCGMinerCommand error: " ++ (show e)
-- How do I match network timeout here?
return r
sendCGMinerCommand :: String -> String -> T.Text -> IO (Maybe BS.ByteString)
sendCGMinerCommand h p s = connect h p $ \(connectionSocket, _) -> do
send connectionSocket $ BL.toStrict . encode $ QueryApi s "0"
mconcat <$> unfoldWhileM (Nothing /=) (recv connectionSocket 4096)
{-
The timeout exception currently looks like this on the command line:
check_cgminer: sendCGMinerCommand error: user error (Network.Simple.TCP.connectSock: Timeout on connect)
CallStack (from HasCallStack):
error, called at src/CheckCgminer.hs:434:39 in check-cgminer-0.7.4.0-BYzPUoKaDMcAXChGVVLKkK:CheckCgminer
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment