Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit 293f03f

Browse files
committed
Add configurable default HTTP timeout
1 parent 4e216d8 commit 293f03f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main/Main.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ data Config = Config
262262
, _configOnDemandPort :: !Port
263263
, _configOnDemandInterface :: !HostPreference
264264
, _configConstantDelayBlockTime :: !Natural
265+
, _configDefaultHTTPTimeout :: !Int
265266
}
266267
deriving (Show, Eq, Ord, Generic)
267268

@@ -287,6 +288,7 @@ defaultConfig = Config
287288
, _configOnDemandPort = 1917
288289
, _configOnDemandInterface = "*"
289290
, _configConstantDelayBlockTime = 30
291+
, _configDefaultHTTPTimeout = 1000000
290292
}
291293

292294
instance ToJSON Config where
@@ -309,6 +311,7 @@ instance ToJSON Config where
309311
, "onDemandPort" .= _configOnDemandPort c
310312
, "onDemandInterface" .= _configOnDemandInterface c
311313
, "constantDelayBlockTime" .= _configConstantDelayBlockTime c
314+
, "defaultHTTPTimeout" .= _configDefaultHTTPTimeout c
312315
]
313316

314317
instance FromJSON (Config -> Config) where
@@ -331,6 +334,7 @@ instance FromJSON (Config -> Config) where
331334
<*< configOnDemandPort ..: "onDemandPort" % o
332335
<*< configOnDemandInterface ..: "onDemandInterface" % o
333336
<*< configConstantDelayBlockTime ..: "constantDelayBlockTime" % o
337+
<*< configDefaultHTTPTimeout ..: "defaultHTTPTimeout" % o
334338
where
335339
parseLogLevel = withText "LogLevel" $ return . logLevelFromText
336340

@@ -403,6 +407,9 @@ parseConfig = id
403407
<*< configOnDemandPort .:: option jsonReader
404408
% long "on-demand-port"
405409
<> help "port on which the on-demand mining server listens"
410+
<*< configDefaultHTTPTimeout .:: option auto
411+
% long "default-http-timeout"
412+
<> help "the default timeout of HTTP requests made by the miner, for example to the node"
406413

407414
-- -------------------------------------------------------------------------- --
408415
-- HTTP Retry Logic
@@ -810,7 +817,7 @@ main = runWithPkgInfoConfiguration mainInfo pkgInfo $ \conf ->
810817
run :: Config -> Logger -> IO ()
811818
run conf logger = do
812819
mgr <- HTTP.newManager (HTTP.mkManagerSettings tlsSettings Nothing)
813-
{ HTTP.managerResponseTimeout = HTTP.responseTimeoutMicro 1000000 }
820+
{ HTTP.managerResponseTimeout = HTTP.responseTimeoutMicro (_configDefaultHTTPTimeout conf) }
814821
-- We don't want to wait too long, because latencies matter in
815822
-- mining. NOTE, however, that for large blocks it can take a while
816823
-- to get new work. This can be an issue with public mining mode.

0 commit comments

Comments
 (0)