Skip to content

Commit

Permalink
Trace retrying
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Sep 5, 2023
1 parent e057b44 commit dedf2fb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hydra-node/src/Hydra/Chain/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Hydra.Prelude
import Hydra.Cardano.Api hiding (Block)

import qualified Cardano.Api.UTxO as UTxO
import Control.Tracer (showTracing, stdoutTracer, traceWith)
import qualified Data.Set as Set
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch)
import Test.QuickCheck (oneof)
Expand Down Expand Up @@ -321,14 +322,18 @@ queryStakePools networkId socket queryPoint =
-- rollback. So what we do is retry 5 times and then give up.
runQuery :: NetworkId -> SocketPath -> QueryPoint -> QueryInMode CardanoMode a -> IO a
runQuery networkId socket point query =
go 5
let tracer = traceWith $ showTracing stdoutTracer
in go tracer 5
where
go n =
go tracer n =
queryNodeLocalState (localNodeConnectInfo networkId socket) maybePoint query >>= \case
Left err ->
if n == (0 :: Int)
then throwIO $ QueryAcquireException err
else threadDelay 1000000 >> go (n - 1)
else do
tracer ("Retrying query... " <> show n <> " Query: " <> show query :: String)
threadDelay 1000000
go tracer (n - 1)
Right result -> pure result
maybePoint =
case point of
Expand Down

0 comments on commit dedf2fb

Please sign in to comment.